Recovering the Populations

No attempts yetTime limit4sMemory limit256 MB

Problem

Byteasar is preparing a problem for a programming contest. He has already written a draft of the statement.

Byteotia has nn cities joined by n1n - 1 two-way roads, laid out so that the road network lets you travel between any two cities. Driving the road between two directly connected cities takes one hour. The cities are numbered from 11 to nn, and aia_i inhabitants live in city ii.

An election is held in Byteotia next year. To keep full control over the vote, the king of Byteotia decided that the vote takes place in a single city. Every inhabitant of Byteotia travels to the city with the ballot box along a shortest route and votes there. All that is left is to choose the city that holds the vote, and this choice depends on many factors. In particular, for every city ii we want to compute the total time all inhabitants of Byteotia need to reach city ii. Call this value bib_i. [...]

Byteasar had already prepared unusually hard tests for the problem, but he accidentally lost half of the data. All that is left of each test is the part describing the roads and the output file with the values bib_i. From that alone Byteasar wants to recover the number of inhabitants of every city of Byteotia.

Input

The first line contains an integer nn (2n3000002 \le n \le 300000), the number of cities in Byteotia. Each of the next n1n - 1 lines contains two integers xix_i, yiy_i (1xi,yin1 \le x_i, y_i \le n) describing one road, which means that city xix_i and city yiy_i are joined by a road. The road network connects all cities.

The next line contains a sequence of nn integers bib_i (0bi1090 \le b_i \le 10^9).

Output

Print a sequence of nn integers aia_i on one line, separated by single spaces. The number aia_i is the number of inhabitants of city ii of Byteotia. Solving Byteasar's problem for the printed sequence aia_i has to give back the sequence bib_i from the input.

The input always admits an answer. Once the road network and the sequence bib_i are fixed, only one sequence aia_i satisfies the condition, so print that sequence.