from collections import deque

import sys

s = sys.stdin.readlines()



n, q = list(map(int, s[0].split()))



tree = [[] for _ in range(n+1)]

for ab in s[1:n]:

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

    tree[a].append(b)

    tree[b].append(a)



counter = [0] * (n+1)

for px in s[n:]:

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

    counter[p] += x



# pop, appendまたはQueueライブラリだと間に合わない

queue = deque([[0,1]])

while queue:

    parent, node = queue.popleft()

    for leaf in tree[node]:

        if leaf == parent:

            continue

        counter[leaf] += counter[node]

        queue.append([node, leaf])



print((*counter[1:]))

from collections import deque

import sys



n, q, *args = list(map(int, open(0).read().split()))

ab = args[:(n-1)*2]

px = args[(n-1)*2:]



tree = [[] for _ in range(n+1)]

for a, b in zip(*[iter(ab)]*2):

    tree[a].append(b)

    tree[b].append(a)



counter = [0] * (n+1)

for p, x in zip(*[iter(px)]*2):

    counter[p] += x



# pop, appendまたはQueueライブラリだと間に合わない

queue = deque([[0,1]])

while queue:

    parent, node = queue.popleft()

    for leaf in tree[node]:

        if leaf == parent:

            continue

        counter[leaf] += counter[node]

        queue.append([node, leaf])



print((*counter[1:]))

from collections import deque
import sys

s = sys.stdin.readlines()
n, q = list(map(int, s[0].split()))
tree = [[] for _ in range(n + 1)]
for ab in s[1:n]:
    a, b = list(map(int, ab.split()))
    tree[a].append(b)
    tree[b].append(a)
counter = [0] * (n + 1)
for px in s[n:]:
    p, x = list(map(int, px.split()))
    counter[p] += x
# pop, appendまたはQueueライブラリだと間に合わない
queue = deque([[0, 1]])
while queue:
    parent, node = queue.popleft()
    for leaf in tree[node]:
        if leaf == parent:
            continue
        counter[leaf] += counter[node]
        queue.append([node, leaf])
print((*counter[1:]))

from collections import deque
import sys

n, q, *args = list(map(int, open(0).read().split()))
ab = args[: (n - 1) * 2]
px = args[(n - 1) * 2 :]
tree = [[] for _ in range(n + 1)]
for a, b in zip(*[iter(ab)] * 2):
    tree[a].append(b)
    tree[b].append(a)
counter = [0] * (n + 1)
for p, x in zip(*[iter(px)] * 2):
    counter[p] += x
# pop, appendまたはQueueライブラリだと間に合わない
queue = deque([[0, 1]])
while queue:
    parent, node = queue.popleft()
    for leaf in tree[node]:
        if leaf == parent:
            continue
        counter[leaf] += counter[node]
        queue.append([node, leaf])
print((*counter[1:]))

-s = sys.stdin.readlines() -n, q = list(map(int, s[0].split())) +n, q, *args = list(map(int, open(0).read().split())) +ab = args[: (n - 1) * 2] +px = args[(n - 1) * 2 :] -for ab in s[1:n]: -    a, b = list(map(int, ab.split())) +for a, b in zip(*[iter(ab)] * 2): -for px in s[n:]: -    p, x = list(map(int, px.split())) +for p, x in zip(*[iter(px)] * 2):