from collections import deque

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

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

ans = [0 for i in range(n)]

for i in range(n-1):

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

    lst[a-1].append(b)

    lst[b-1].append(a)

for i in range(q):

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

    ans[p-1] += x

q = deque([1])

while q:

    x = q.popleft()

    for i in lst[x-1]:

        q.append(i)

        lst[i-1].remove(x)

        ans[i-1] += ans[x-1]

print((" ".join(map(str,ans))))

from collections import deque

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

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

counter = [0]*(N+1)

for i in range(N-1):

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

    tree[a].append(b)

    tree[b].append(a)

for i in range(Q):

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

    counter[p] += x

already = set()

d = deque([1])



while d:

    a = d.popleft()

    for b in tree[a]:

        if not b in already:

            counter[b] += counter[a]

            d.append(b)

    already.add(a)



print((*counter[1:]))
from collections import deque

n, q = list(map(int, input().split()))
lst = [[] for i in range(n)]
ans = [0 for i in range(n)]
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    lst[a - 1].append(b)
    lst[b - 1].append(a)
for i in range(q):
    p, x = list(map(int, input().split()))
    ans[p - 1] += x
q = deque([1])
while q:
    x = q.popleft()
    for i in lst[x - 1]:
        q.append(i)
        lst[i - 1].remove(x)
        ans[i - 1] += ans[x - 1]
print((" ".join(map(str, ans))))

from collections import deque

N, Q = list(map(int, input().split()))
tree = [[] for _ in range(N + 1)]
counter = [0] * (N + 1)
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    tree[a].append(b)
    tree[b].append(a)
for i in range(Q):
    p, x = list(map(int, input().split()))
    counter[p] += x
already = set()
d = deque([1])
while d:
    a = d.popleft()
    for b in tree[a]:
        if not b in already:
            counter[b] += counter[a]
            d.append(b)
    already.add(a)
print((*counter[1:]))

-n, q = list(map(int, input().split())) -lst = [[] for i in range(n)] -ans = [0 for i in range(n)] -for i in range(n - 1): +N, Q = list(map(int, input().split())) +tree = [[] for _ in range(N + 1)] +counter = [0] * (N + 1) +for i in range(N - 1): -    lst[a - 1].append(b) -    lst[b - 1].append(a) -for i in range(q): +    tree[a].append(b) +    tree[b].append(a) +for i in range(Q): -    ans[p - 1] += x -q = deque([1]) -while q: -    x = q.popleft() -    for i in lst[x - 1]: -        q.append(i) -        lst[i - 1].remove(x) -        ans[i - 1] += ans[x - 1] -print((" ".join(map(str, ans)))) +    counter[p] += x +already = set() +d = deque([1]) +while d: +    a = d.popleft() +    for b in tree[a]: +        if not b in already: +            counter[b] += counter[a] +            d.append(b) +    already.add(a) +print((*counter[1:]))