In the flourishing land of Unionville, many streams flow from the mountains to nourish the village below. At various points, a stream may diverge into two, or two streams may converge into one. This occurs at exactly
Recently, some of the junctions have become polluted! Water at every junction has a measurable pollution value, which begins at
Until the pollution is cleaned up, the village chief needs to decide the safest places to source water for agriculture. Please help him determine the average pollution value of the water at each junction.
Constraints
All water starts at a single diverging source junction, which can flow to every other junction.
It is impossible to start at a junction, travel any number of streams, and return to the same junction.
The volume of water at every junction is guaranteed to be greater than
Input Specification
The first line contains two integers,
The
The next line contains
Output Specification
Output
Sample Input
6 8
2 6 100
3 4 41
3 2 59
4 2 100
5 4 27
5 3 73
6 1 62
6 1 38
8 73 40 36 100 54
Sample Output
284.6948
222.6948
140
157.029334270156
100
276.6948
Explanation for Sample Output
The river system looks like this:
Comments