DMPG '19 G5 - Hunting the White Whale
View as PDFSubaru and Rem are hunting down the white whale. They currently have a list of  locations where the white whale has been rumoured to appear. There are 
 roads that connect every location to every other location. The 
th of these typically sees 
 travelers per day.
If the white whale travels along these roads, it continually travels along a single path that sees a total of  travelers per day, picked uniformly at random from all such paths. Doing so means that it will pass all locations that are on this path. Thus Rem asks Subaru 
 questions: if we wait at node 
, what is the probability we will encounter the whale?
Constraints
For all subtasks:
Subtask 1 [9%]
The network of roads forms the simplest possible line: For , road 
 connects locations 
 and 
.
Subtask 2 [12%]
Subtask 3 [22%]
Subtask 4 [57%]
Input Specification
The first line of input will contain two space-separated integers,  and 
.
The next  lines will each contain 3 integers: 
, indicating there is a road between locations 
 and 
, with 
 travelers per day.
Output Specification
You should output  lines, where each is the probability Rem and Subaru encounter the white whale, expressed as a fraction in lowest terms.
Sample Input
5 4
1 3 3
2 3 3
3 4 1
4 5 3
Sample Output
1 / 3
1 / 3
1 / 1
1 / 1
1 / 3
Explanation for Sample Output
The possible paths are:
Locations  and 
 appear on all 
 paths, but locations 
, 
, and 
 only appear on a single path each.
Comments
Just in case it isn't clear from the problem statement:
It may be possible that there are no paths that see a total of
 travelers. [Perhaps the white whale is only a legend.] In this case, you should print 
0 / 1for all nodes.what if a path has no chance? should it be
0 / 1?