A weighted tree is a tree where every edge carries a number giving that edge's length. All lengths are positive.
For each node of the tree, find the largest distance from that node to any other node. The distance between two nodes is the sum of the edge lengths along the path that joins them.
Input
The first line contains the number of nodes N. (2≤N≤50000)
Each of the next N−1 lines describes one edge with three positive integers. The first two are the labels of the nodes the edge joins (from 1 to N), and the third is the length of the edge. The total length of all edges does not exceed 231−1. The input always describes a valid tree.
Output
Print exactly N lines. The k-th line contains the distance from node k to the node farthest from it. (k=1,2,…,N)