#Lutece0148. H-edges
H-edges
Migrated from Lutece 148 H-edges
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
A simple graph is given with nodes and edges, each edge's length is . Given you the node , for each node , you should calculate the odd and even shortest distance from the node (). (that is the shortest distance with length of odd and even, the route isn't necessarily a simple route).
We define the odd shortest distance to be odd(), and the even shortest distance to be even(). And we call the maximal one of them to be max(). We say a route from to whose length is max() is a beautiful route (not necessarily only one), and every beautiful route's last edge is defined to be the T-edge. If there is no odd shortest route or no even shortest route for node , then there are no beautiful routes ended by node .For those edges which is not a T-edge, we say them H-edges.
Now, can you help us to find out all the H-edges.
Input
In the first line, you will get a number denotes the number of test cases.
For each test case,
In the first line, you will get number () and (), denote the number of nodes and edges.
Then lines comes,
In the line, numbers and are given, indicate there is a road between node and node ,() the symbol of this road is .
Then a number is given as described above.
Output
For each test case, you should output lines.
The first line contain a number denotes the number of H-edges.
In the second line, you should output numbers denote the symbol of all the H-edges in ascending order.
Samples
1
8 8
0 1
1 2
2 3
0 4
2 5
4 5
5 6
6 7
0
2
1 4
Resources
Sichuan State Programming Contest 2008