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

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

for _ in range(N - 1):

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

    a -= 1

    b -= 1

    graph[a].append(b)

    graph[b].append(a)



count = [0] * N

for _ in range(Q):

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

    count[p - 1] += x



used = [False] * N

stack = [0]

used[0] = True

while len(stack) != 0:

    tmp = stack.pop()

    for i in graph[tmp]:

        if not used[i]:

            stack.append(i)

            count[i] += count[tmp]

            used[i] = True



print((*count))
import sys

input = sys.stdin.readline

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

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

for _ in range(N - 1):

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

    a -= 1

    b -= 1

    graph[a].append(b)

    graph[b].append(a)



count = [0] * N

for _ in range(Q):

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

    count[p - 1] += x



used = [False] * N

stack = [0]

s_pop = stack.pop

s_append = stack.append

used[0] = True

while len(stack) != 0:

    tmp = s_pop()

    for i in graph[tmp]:

        if not used[i]:

            s_append(i)

            count[i] += count[tmp]

            used[i] = True



print((*count))
N, Q = list(map(int, input().split()))
graph = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
count = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    count[p - 1] += x
used = [False] * N
stack = [0]
used[0] = True
while len(stack) != 0:
    tmp = stack.pop()
    for i in graph[tmp]:
        if not used[i]:
            stack.append(i)
            count[i] += count[tmp]
            used[i] = True
print((*count))

import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
graph = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
count = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    count[p - 1] += x
used = [False] * N
stack = [0]
s_pop = stack.pop
s_append = stack.append
used[0] = True
while len(stack) != 0:
    tmp = s_pop()
    for i in graph[tmp]:
        if not used[i]:
            s_append(i)
            count[i] += count[tmp]
            used[i] = True
print((*count))

+import sys + +input = sys.stdin.readline +s_pop = stack.pop +s_append = stack.append -    tmp = stack.pop() +    tmp = s_pop() -            stack.append(i) +            s_append(i)