from collections import deque



n, q = [int(i) for i in input().split()]

ab = [[int(i) for i in input().split()] for _ in range(n-1)]

px = [[int(i) for i in input().split()] for _ in range(q)]



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

for a, b in ab:

    tree[a].append(b)

    tree[b].append(a)



counter = [0] * (n+1)

for p, x in px:

    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

n, q = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for _ in range(n - 1)]
px = [[int(i) for i in input().split()] for _ in range(q)]
tree = [[] for _ in range(n + 1)]
for a, b in ab:
    tree[a].append(b)
    tree[b].append(a)
counter = [0] * (n + 1)
for p, x in px:
    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:]))

+import sys -n, q = [int(i) for i in input().split()] -ab = [[int(i) for i in input().split()] for _ in range(n - 1)] -px = [[int(i) for i in input().split()] for _ in range(q)] +s = sys.stdin.readlines() +n, q = list(map(int, s[0].split())) -for a, b in ab: +for ab in s[1:n]: +    a, b = list(map(int, ab.split())) -for p, x in px: +for px in s[n:]: +    p, x = list(map(int, px.split()))