n,q=map(int,input().split())

link=[[] for _ in range(n)]

for _ in range(n-1):

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

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



under=[[] for i in range(n)]

for i in range(n-1, -1, -1):

    l=link[i]

    for j in l:

        under[i].append(j)



#for i in link:

#    print(i)

#print()

#for i in under:

#    print(i)





ans=[0]*n

for _ in range(q):

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

    ans[p-1]+=x



for i in range(n):

    for j in under[i]:

        ans[j]+=ans[i]

for i in ans:

    print("{} ".format(i), end="")

print()

from collections import deque

import sys

input = sys.stdin.readline



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

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

for _ in range(N - 1):

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

    edge[a].append(b)

    edge[b].append(a)

query = [list(map(int, input().split())) for _ in range(Q)]



score = [0] * (N + 1)

for n, p in query:

    score[n] += p



seen = [0] * (N + 1)

seen[1] = 1

node = deque([1])

while node:

    s = node.popleft()

    for t in edge[s]:

        if not seen[t]:

            seen[t] = 1

            score[t] += score[s]

            node.append(t)



print((*score[1:]))

n, q = map(int, input().split())
link = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    link[a - 1].append(b - 1)
under = [[] for i in range(n)]
for i in range(n - 1, -1, -1):
    l = link[i]
    for j in l:
        under[i].append(j)
# for i in link:
#    print(i)
# print()
# for i in under:
#    print(i)
ans = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    ans[p - 1] += x
for i in range(n):
    for j in under[i]:
        ans[j] += ans[i]
for i in ans:
    print("{} ".format(i), end="")
print()

from collections import deque
import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    edge[a].append(b)
    edge[b].append(a)
query = [list(map(int, input().split())) for _ in range(Q)]
score = [0] * (N + 1)
for n, p in query:
    score[n] += p
seen = [0] * (N + 1)
seen[1] = 1
node = deque([1])
while node:
    s = node.popleft()
    for t in edge[s]:
        if not seen[t]:
            seen[t] = 1
            score[t] += score[s]
            node.append(t)
print((*score[1:]))

-n, q = map(int, input().split()) -link = [[] for _ in range(n)] -for _ in range(n - 1): -    a, b = map(int, input().split()) -    link[a - 1].append(b - 1) -under = [[] for i in range(n)] -for i in range(n - 1, -1, -1): -    l = link[i] -    for j in l: -        under[i].append(j) -# for i in link: -#    print(i) -# print() -# for i in under: -#    print(i) -ans = [0] * n -for _ in range(q): -    p, x = map(int, input().split()) -    ans[p - 1] += x -for i in range(n): -    for j in under[i]: -        ans[j] += ans[i] -for i in ans: -    print("{} ".format(i), end="") -print() +from collections import deque +import sys + +input = sys.stdin.readline +N, Q = list(map(int, input().split())) +edge = [[] for _ in range(N + 1)] +for _ in range(N - 1): +    a, b = list(map(int, input().split())) +    edge[a].append(b) +    edge[b].append(a) +query = [list(map(int, input().split())) for _ in range(Q)] +score = [0] * (N + 1) +for n, p in query: +    score[n] += p +seen = [0] * (N + 1) +seen[1] = 1 +node = deque([1]) +while node: +    s = node.popleft() +    for t in edge[s]: +        if not seen[t]: +            seen[t] = 1 +            score[t] += score[s] +            node.append(t) +print((*score[1:]))