import sys

sys.setrecursionlimit(10**9)



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

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

for _ in range(N-1):

	at,bt = map(int ,input().split())

	E[at].append(bt)

	E[bt].append(at)

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

for _ in range(Q):

	pt,xt = map(int, input().split())

	cnt[pt] += xt



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

q = [[1,-1]]

while q:

	cp, root = q.pop()

	for np in E[cp]:

		if np == root:

			continue

		cnt[np] += cnt[cp]

		q.append([np,cp])



cnt.pop(0)

for c in cnt:

	print(c, end = " ")

print()

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

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

for _ in range(N-1):

	ta,tb = list(map(int, input().split()))

	E[ta].append(tb)

	E[tb].append(ta)



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



for _ in range(Q):

	tp, tx = list(map(int, input().split()))

	cnt[tp] += tx



q = [[1,0]]

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

flg[0] = 1



while q:

	cp, cost = q.pop()

	cnt[cp] += cost

	flg[cp] = 1

	for np in E[cp]:

		if flg[np] == 1:

			continue

		q.append([np, cnt[cp]])



print((*cnt[1:]))
import sys

sys.setrecursionlimit(10**9)
N, Q = map(int, input().split())
E = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    at, bt = map(int, input().split())
    E[at].append(bt)
    E[bt].append(at)
cnt = [0 for _ in range(N + 1)]
for _ in range(Q):
    pt, xt = map(int, input().split())
    cnt[pt] += xt
flg = [0 for _ in range(N + 1)]
q = [[1, -1]]
while q:
    cp, root = q.pop()
    for np in E[cp]:
        if np == root:
            continue
        cnt[np] += cnt[cp]
        q.append([np, cp])
cnt.pop(0)
for c in cnt:
    print(c, end=" ")
print()

N, Q = list(map(int, input().split()))
E = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    ta, tb = list(map(int, input().split()))
    E[ta].append(tb)
    E[tb].append(ta)
cnt = [0 for _ in range(N + 1)]
for _ in range(Q):
    tp, tx = list(map(int, input().split()))
    cnt[tp] += tx
q = [[1, 0]]
flg = [0 for _ in range(N + 1)]
flg[0] = 1
while q:
    cp, cost = q.pop()
    cnt[cp] += cost
    flg[cp] = 1
    for np in E[cp]:
        if flg[np] == 1:
            continue
        q.append([np, cnt[cp]])
print((*cnt[1:]))

-import sys - -sys.setrecursionlimit(10**9) -N, Q = map(int, input().split()) +N, Q = list(map(int, input().split())) -    at, bt = map(int, input().split()) -    E[at].append(bt) -    E[bt].append(at) +    ta, tb = list(map(int, input().split())) +    E[ta].append(tb) +    E[tb].append(ta) -    pt, xt = map(int, input().split()) -    cnt[pt] += xt +    tp, tx = list(map(int, input().split())) +    cnt[tp] += tx +q = [[1, 0]] -q = [[1, -1]] +flg[0] = 1 -    cp, root = q.pop() +    cp, cost = q.pop() +    cnt[cp] += cost +    flg[cp] = 1 -        if np == root: +        if flg[np] == 1: -        cnt[np] += cnt[cp] -        q.append([np, cp]) -cnt.pop(0) -for c in cnt: -    print(c, end=" ") -print() +        q.append([np, cnt[cp]]) +print((*cnt[1:]))