Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i.  Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0.  Now, the following Q operations will be performed:    * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j.  Find the value of the counter on each vertex after all operations.
#!/usr/bin/env python3
from collections import deque

n, q = map(int, input().split())
a, b = [0] * (-1 + n), [0] * (n - 1)
path = [[] for _ in range(n)]
for i in range(n - 1):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
    path[a[i]].append(b[i])
    path[b[i]].append(a[i])
add = [0] * n
for i in range(q):
    p, x = map(int, input().split())
    p -= 1
    add[p] += x
q = deque()
ans = [0] * n

q.append(0)
visit = [0] * n
visit[0] = 1
ans[0] = add[0]
while q:
    pos = q.popleft()
    for v in path[pos]:
        if visit[v] == 0:
            ans[v] = ans[pos] + add[v]
            q.append(v)
            visit[v] = 1
print(ans)

#!/usr/bin/env python3
from collections import deque

n, q = map(int, input().split())
a, b = [0] * (-1 + n), [0] * (n - 1)
path = [[] for _ in range(n)]
for i in range(n - 1):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
    path[a[i]].append(b[i])
    path[b[i]].append(a[i])
add = [0] * n
for i in range(q):
    p, x = map(int, input().split())
    p -= 1
    add[p] += x
q = deque()
ans = [0] * n

q.append(0)
visit = [0] * n
visit[0] = 1
ans[0] = add[0]
while q:
    pos = q.popleft()
    for v in path[pos]:
        if visit[v] == 0:
            ans[v] = ans[pos] + add[v]
            q.append(v)
            visit[v] = 1
print(*ans)
