Sum
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Roman’s parents gave him an undirected connected weighted graph with vertices and edges. Roman wants to know the sum of all the paths’ lengths in this graph. Let’s consider the path’s length as the sum of all the edges that lie on this path. Roman said that the path from to is the same as from to , so he doesn’t distinguish them.
Input
The first line contains the single integer number — the number of vertices in the graph. It is followed by lines containing the description of the edges. Every line of description consists of three integers: the vertices connected by the edge (labeled from to ) and the edge’s weight.
Output
Print the sum of all the paths’ lengths in the given graph modulo .
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 2K
Acceptance rate 36%