from collections import deque

import sys

input = sys.stdin.readline



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

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



for i in range(N-1):

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

    graph[a-1].append(b-1)

    graph[b-1].append(a-1)



#print(graph)

v = [0]*N

for i in range(Q):

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

    v[p-1] += x



notv = [True]*N

notv[0] = False

stack = deque([0])



while stack:

    now = stack.popleft()

    for i in graph[now]:

        if notv[i]:

            notv[i] = False

            stack.append(i)

            v[i] += v[now]



print((*v))
from collections import deque

import sys

input = sys.stdin.readline



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

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



for i in range(N-1):

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

    graph[a-1].append(b-1)

    graph[b-1].append(a-1)



#print(graph)

v = [0]*N

for i in range(Q):

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

    v[p-1] += x



notv = [True]*N

notv[0] = False

stack = deque([0])



while stack:

    now = stack.pop()

    for i in graph[now]:

        if notv[i]:

            notv[i] = False

            stack.append(i)

            v[i] += v[now]



print((*v))
from collections import deque
import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
graph = [[] for i in range(N)]
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
# print(graph)
v = [0] * N
for i in range(Q):
    p, x = list(map(int, input().split()))
    v[p - 1] += x
notv = [True] * N
notv[0] = False
stack = deque([0])
while stack:
    now = stack.popleft()
    for i in graph[now]:
        if notv[i]:
            notv[i] = False
            stack.append(i)
            v[i] += v[now]
print((*v))

from collections import deque
import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
graph = [[] for i in range(N)]
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
# print(graph)
v = [0] * N
for i in range(Q):
    p, x = list(map(int, input().split()))
    v[p - 1] += x
notv = [True] * N
notv[0] = False
stack = deque([0])
while stack:
    now = stack.pop()
    for i in graph[now]:
        if notv[i]:
            notv[i] = False
            stack.append(i)
            v[i] += v[now]
print((*v))

-    now = stack.popleft() +    now = stack.pop()