#Lutece0146. Flood
Flood
Migrated from Lutece 146 Flood
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
villages are connected with roads, no two villages connected with more than one road.
However, the flood comes, each road has a probability to be submerged, now you should tell us the probability that all the villages are connected (that is from one village, we can reach any other villages with the roads that are not submerged).
Input
In the first line, you will get a number denotes the number of test case.
For each test case,
In the first line, you will get number () and (), as described above.
In the next lines, each line contains numbers , , , indicate there is a road between village and village that have a probability of to be submerged.
Output
For each test case, you should output in a line, give the answer round to digital.
Samples
1
3 3
1 2 0.2
1 3 0.5
2 3 0.7
0.550
Note
The probability is all the roads are not submerged$) + (0.2\times 0.5\times 0.3+0.8\times 0.5\times 0.3+0.8\times 0.5\times 0.7) ($one of the roads is submerged
Resources
Sichuan State Programming Contest 2008