Emma roasts coffee beans and works as a barista. She has linked her farms into a tree with N vertices, and the farms are numbered 1 through N. Each edge means you can travel between those two farms, and the weight of an edge is the travel distance.
Emma wants to pick one farm and set up a roasting facility next to it. To place it well she needs to know how far the other farms are from the facility in total. For every farm, find the sum of the shortest distances from all the other farms to that farm.
Input
The first line contains N. (1≤N≤3×105)
Each of the next N−1 lines contains three integers u, v, and d. Farm u and farm v are connected to each other and the distance between them is d. (1≤u,v≤N, 1≤d≤5)
The given graph is a tree.
Output
Print N lines. Line i contains the sum of the shortest distances from all the other farms to farm i.