Going from city u to city v via the unique shortest path, one may pass roads e1, e2, ..., ek in order. Bobo denotes
For each city u, find out
The input consists of several test cases and is terminated by end-of-file.
The first line of each test case contains an integer n.
The i-th of the following (n - 1) lines contains 3 integers ai, bi, ci.
For each test case, print n integers f1, f2, ..., fn.
2 1 2 1 4 1 2 1 2 3 2 3 4 1
0 0 2 1 1 2
* 1 ≤ n ≤ 105
* 1 ≤ ai, bi ≤ n
* 1 ≤ ci ≤ 105
* The sum of n does not exceed 106.

暂无题解