100 atcoder#ABC138D. [ABC138D] Ki

[ABC138D] Ki

Score : 400400 points

Problem Statement

Given is a rooted tree with NN vertices numbered 11 to NN. The root is Vertex 11, and the ii-th edge (1iN1)(1 \leq i \leq N - 1) connects Vertex aia_i and bib_i.

Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 00.

Now, the following QQ operations will be performed:

  • Operation jj (1jQ)(1 \leq j \leq Q): Increment by xjx_j the counter on every vertex contained in the subtree rooted at Vertex pjp_j.

Find the value of the counter on each vertex after all operations.

Constraints

  • 2N2×1052 \leq N \leq 2 \times 10^5
  • 1Q2×1051 \leq Q \leq 2 \times 10^5
  • 1ai<biN1 \leq a_i < b_i \leq N
  • 1pjN1 \leq p_j \leq N
  • 1xj1041 \leq x_j \leq 10^4
  • The given graph is a tree.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN QQ

a1a_1 b1b_1

::

aN1a_{N-1} bN1b_{N-1}

p1p_1 x1x_1

::

pQp_Q xQx_Q

Output

Print the values of the counters on Vertex 1,2,,N1, 2, \ldots, N after all operations, in this order, with spaces in between.

4 3
1 2
2 3
2 4
2 10
1 100
3 1
100 110 111 110

The tree in this input is as follows:

Figure

Each operation changes the values of the counters on the vertices as follows:

  • Operation 11: Increment by 1010 the counter on every vertex contained in the subtree rooted at Vertex 22, that is, Vertex 2,3,42, 3, 4. The values of the counters on Vertex 1,2,3,41, 2, 3, 4 are now 0,10,10,100, 10, 10, 10, respectively.
  • Operation 22: Increment by 100100 the counter on every vertex contained in the subtree rooted at Vertex 11, that is, Vertex 1,2,3,41, 2, 3, 4. The values of the counters on Vertex 1,2,3,41, 2, 3, 4 are now 100,110,110,110100, 110, 110, 110, respectively.
  • Operation 33: Increment by 11 the counter on every vertex contained in the subtree rooted at Vertex 33, that is, Vertex 33. The values of the counters on Vertex 1,2,3,41, 2, 3, 4 are now 100,110,111,110100, 110, 111, 110, respectively.
6 2
1 2
1 3
2 4
3 6
2 5
1 10
1 10
20 20 20 20 20 20