import sys

input = sys.stdin.readline



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

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

cnt = [0] * (N + 1)



for i in range(N - 1):

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

    graph[a].append(b)

    graph[b].append(a)



for i in range(Q):

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

    cnt[p] += x



wait = [1]

parent = [0] * (N + 1)

while wait:

    temp = wait.pop()



    # 頂点tempについて

    for i in graph[temp]:

        if i != parent[temp]:

            parent[i] = temp

            wait.append(i)

            cnt[i] += cnt[temp]





print((' '.join(map(str, cnt[1:]))))
import sys



readline = sys.stdin.readline

read = sys.stdin.read



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

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

cnt = [0] * (N + 1)



for _ in range(N - 1):

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

    graph[a].append(b)

    graph[b].append(a)



px = list(map(int, read().split()))

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

    cnt[p] += x



stack = [1]

checked = [False] * (N + 1)

checked[1] = True

while stack:

    V = stack.pop()

    for i in graph[V]:

        if checked[i]:

            continue

        checked[i] = True

        stack.append(i)

        cnt[i] += cnt[V]



print((' '.join(map(str, cnt[1:]))))

import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
graph = [[] for _ in range(N + 1)]
cnt = [0] * (N + 1)
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    graph[a].append(b)
    graph[b].append(a)
for i in range(Q):
    p, x = list(map(int, input().split()))
    cnt[p] += x
wait = [1]
parent = [0] * (N + 1)
while wait:
    temp = wait.pop()
    # 頂点tempについて
    for i in graph[temp]:
        if i != parent[temp]:
            parent[i] = temp
            wait.append(i)
            cnt[i] += cnt[temp]
print((" ".join(map(str, cnt[1:]))))

import sys

readline = sys.stdin.readline
read = sys.stdin.read
N, Q = list(map(int, readline().split()))
graph = [[] for _ in range(N + 1)]
cnt = [0] * (N + 1)
for _ in range(N - 1):
    a, b = list(map(int, readline().split()))
    graph[a].append(b)
    graph[b].append(a)
px = list(map(int, read().split()))
for p, x in zip(*[px] * 2):
    cnt[p] += x
stack = [1]
checked = [False] * (N + 1)
checked[1] = True
while stack:
    V = stack.pop()
    for i in graph[V]:
        if checked[i]:
            continue
        checked[i] = True
        stack.append(i)
        cnt[i] += cnt[V]
print((" ".join(map(str, cnt[1:]))))

-input = sys.stdin.readline -N, Q = list(map(int, input().split())) +readline = sys.stdin.readline +read = sys.stdin.read +N, Q = list(map(int, readline().split())) -for i in range(N - 1): -    a, b = list(map(int, input().split())) +for _ in range(N - 1): +    a, b = list(map(int, readline().split())) -for i in range(Q): -    p, x = list(map(int, input().split())) +px = list(map(int, read().split())) +for p, x in zip(*[px] * 2): -wait = [1] -parent = [0] * (N + 1) -while wait: -    temp = wait.pop() -    # 頂点tempについて -    for i in graph[temp]: -        if i != parent[temp]: -            parent[i] = temp -            wait.append(i) -            cnt[i] += cnt[temp] +stack = [1] +checked = [False] * (N + 1) +checked[1] = True +while stack: +    V = stack.pop() +    for i in graph[V]: +        if checked[i]: +            continue +        checked[i] = True +        stack.append(i) +        cnt[i] += cnt[V]