N,Q = map(int,input().split())

# 親の番号 < 子の番号

edge = [[] for _ in range(N)]

for _ in range(N-1):

    a,b = map(int,input().split())

    edge[a-1].append(b-1)

    edge[b-1].append(a-1)

vertices = [0] * N

for _ in range(Q):

    p,x = map(int,input().split())

    vertices[p-1] += x



from collections import deque



que = deque([(-1,0)])

while que:

    pre,now = que.popleft()

    cost = vertices[now]

    for e in edge[now]:

        if e == pre:

            continue

        vertices[e] += cost

        que.append((now,e))



print(*vertices, sep=" ")

from collections import deque



N,Q = list(map(int, input().split()))

edge = [[] for _ in range(N)]

for _ in range(N - 1):

    a,b = list(map(int, input().split()))

    edge[a-1].append(b-1)

    edge[b-1].append(a-1)



cnt = [0] * N

for _ in range(Q):

    p,x = list(map(int, input().split()))

    cnt[p - 1] += x



ans = [-1] * N

que = deque([0])

ans[0] = cnt[0]

while que:

    v = que.popleft()

    for w in edge[v]:

        if ans[w] < 0:

            ans[w] = ans[v] + cnt[w]

            que.append(w)



print((*ans))
N, Q = map(int, input().split())
# 親の番号 < 子の番号
edge = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)
vertices = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    vertices[p - 1] += x
from collections import deque

que = deque([(-1, 0)])
while que:
    pre, now = que.popleft()
    cost = vertices[now]
    for e in edge[now]:
        if e == pre:
            continue
        vertices[e] += cost
        que.append((now, e))
print(*vertices, sep=" ")

from collections import deque

N, Q = list(map(int, input().split()))
edge = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)
cnt = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    cnt[p - 1] += x
ans = [-1] * N
que = deque([0])
ans[0] = cnt[0]
while que:
    v = que.popleft()
    for w in edge[v]:
        if ans[w] < 0:
            ans[w] = ans[v] + cnt[w]
            que.append(w)
print((*ans))

-N, Q = map(int, input().split()) -# 親の番号 < 子の番号 +from collections import deque + +N, Q = list(map(int, input().split())) -    a, b = map(int, input().split()) +    a, b = list(map(int, input().split())) -vertices = [0] * N +cnt = [0] * N -    p, x = map(int, input().split()) -    vertices[p - 1] += x -from collections import deque - -que = deque([(-1, 0)]) +    p, x = list(map(int, input().split())) +    cnt[p - 1] += x +ans = [-1] * N +que = deque([0]) +ans[0] = cnt[0] -    pre, now = que.popleft() -    cost = vertices[now] -    for e in edge[now]: -        if e == pre: -            continue -        vertices[e] += cost -        que.append((now, e)) -print(*vertices, sep=" ") +    v = que.popleft() +    for w in edge[v]: +        if ans[w] < 0: +            ans[w] = ans[v] + cnt[w] +            que.append(w) +print((*ans))