from collections import deque, defaultdict, Counter

import sys

input = sys.stdin.readline



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

ab = [list(map(int, input().split())) for _ in range(N - 1)]

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



# build tree

tree = defaultdict(list)

for a, b in ab:

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

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



dic = defaultdict(int)

for p, x in px:

    dic[p - 1] += x



ans = [0] * N

checked = [0] * N

checked[0] = 1

q = deque([0])



while q:

    n = q.popleft()

    ans[n] += dic[n]

    for u in tree[n]:

        if checked[u]:

            continue

        ans[u] += ans[n]

        checked[u] = 1

        q.append(u)

print((*ans))
from collections import deque, defaultdict, Counter

import sys

input = sys.stdin.readline



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

ab = [list(map(int, input().split())) for _ in range(N - 1)]

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



# build tree

tree = defaultdict(list)

for a, b in ab:

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

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



# 同じノードがきたらまとめておく

# (複数回DFSしない)

dic = defaultdict(int)

for p, x in px:

    dic[p - 1] += x



ans = [0] * N

checked = [False] * N

q = deque([0])



while q:

    n = q.pop()

    checked[n] = True

    ans[n] += dic[n]

    for u in tree[n]:

        if checked[u]:

            continue

        ans[u] += ans[n]

        q.append(u)

print((*ans))
from collections import deque, defaultdict, Counter
import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]
# build tree
tree = defaultdict(list)
for a, b in ab:
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)
dic = defaultdict(int)
for p, x in px:
    dic[p - 1] += x
ans = [0] * N
checked = [0] * N
checked[0] = 1
q = deque([0])
while q:
    n = q.popleft()
    ans[n] += dic[n]
    for u in tree[n]:
        if checked[u]:
            continue
        ans[u] += ans[n]
        checked[u] = 1
        q.append(u)
print((*ans))

from collections import deque, defaultdict, Counter
import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]
# build tree
tree = defaultdict(list)
for a, b in ab:
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)
# 同じノードがきたらまとめておく
# (複数回DFSしない)
dic = defaultdict(int)
for p, x in px:
    dic[p - 1] += x
ans = [0] * N
checked = [False] * N
q = deque([0])
while q:
    n = q.pop()
    checked[n] = True
    ans[n] += dic[n]
    for u in tree[n]:
        if checked[u]:
            continue
        ans[u] += ans[n]
        q.append(u)
print((*ans))

+# 同じノードがきたらまとめておく +# (複数回DFSしない) -checked = [0] * N -checked[0] = 1 +checked = [False] * N -    n = q.popleft() +    n = q.pop() +    checked[n] = True -        checked[u] = 1