题目描述

Eezie, a pie maniac, would like to have some pies with her friends on a hot summer day. However, the weather is so hot that she can't go outdoors and has to call for the delivery service.

The city Eezie lives in can be represented by $N$ nodes connected by $N - 1$ edges, and the city center is node $1$. In other words, the city is a rooted tree, root of which is node $1$. There are $N$ pie houses in the city, the $i$-th on node $i$. For some reason, a pie house on node $i$ can only deliver its pie to nodes on the simple path from node $i$ to node $1$.

Eezie is a bit worried that a pie might lose its flavor during the deliver. After some careful calculation, she decided that a pie from the $i$-th pie house can maintain its flavor if the distance it is delivered does not exceed its flavor-loss-distance $d_i$. The distance between two nodes on the tree is the number of edges on the simple path between them.

Now, Eezie wants to order some pies for all her friends who live on different nodes of the tree. Therefore, she wants you to calculate for each node how many pie houses can deliver their pie to the node without flavor loss.


输入格式

The first line contains an integer $N(1\le N \le 2\times 10^6)$, representing the number of nodes of the city Eezie lives in.

Each of the next $N - 1$ lines contains two integers $u, v(1\le u,v \le N)$, representing an edge. It is guaranteed that the edges form a tree.
The last line contains $N$ integers $d_1, d_2, \cdots, d_N(0\le d_i \le N)$, representing the maximum travel distances for pies from pie houses.


输出格式

Output $N$ integers in a line, the $i$-th integer representing the answer for node $i$.


样例数据

输入

10
1 2
2 3
2 4
3 5
4 6
4 7
1 8
8 9
8 10
0 0 1 2 2 5 3 1 0 2

输出

6 6 2 3 1 1 1 2 1 1

备注


操作

评测记录

优秀代码

信息

时间限制: 3s
内存限制: 512MB
评测模式: Normal

题解