The Dinotrux are facing the biggest and baddest challenge of all time. D-Structs and his gang are coming to attack the colony so Ty and Revvit are planning to fight back. Since they have a big colony to maintain; they are planning to shrink it such that they have better focus on the rest.
They live in a colony where there are n rest stops, which are connected by m bidirectional roads. Since they built the rest stops and also strengthened the roads time to time, they know which roads are strong and which are not.
Building rest stops are hard but roads are easy. So, Ty and Revvit are planning to do the following two things:
- Destroy as many roads as possible but all the rest stops should still be reachable (directly or indirectly) from one another.
- They also want to destroy in such a way that the summation of the strengths of the remaning roads is as strong as possible.
Since there could be multiple solutions, they are seeking your help to figure out how many ways they could do the destruction.
Input
Input starts with an integer T (≤ 20), denoting the number of test cases.
Each case starts with a blank line followed by two integers n and m (2 ≤ n ≤ 200, m ≥ 0). Each of the next m lines will contain three integers u v w (1 ≤ u, v ≤ n, u ≠ v, 0 < w ≤ 15000) denoting a road between rest stop u and v with strength w. A stronger road means higher w. There will be at most one road between any two rest stops.
Output
For each case, print the case number and the number of ways Ty and Revvit can destroy the roads. Since the result could be very large, print the result modulo 1000210433 (which is a prime).
Sample
Sample Input | Sample Output |
---|---|
3 4 3 1 4 1 2 3 1 3 4 1 5 7 4 5 2 2 4 4 5 1 1 1 2 3 2 3 4 3 4 4 4 1 3 3 0 | Case 1: 1 Case 2: 6 Case 3: 0 |
Notes
For case 1, no road can be destroyed. So, we have one solution.
For case 2, the 6 solutions are below:
Roads Destroyed | View | |
---|---|---|
Initial map | - | |
Solution 1 | (5 1) (4 1) (2 3) | |
Solution 2 | (5 1) (4 1) (2 4) | |
Solution 3 | (5 1) (4 1) (3 4) | |
Solution 4 | (5 1) (1 2) (2 3) | |
Solution 5 | (5 1) (1 2) (2 4) | |
Solution 6 | (5 1) (1 2) (3 4) |
- For case 3, the rest stops are not reachable from one another. Thus, we don't have any solution.