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

ans=[0]*N

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

for i in range(N-1):

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

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

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

for i in range(Q):

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

 ans[p-1]+=q

# dfs

stack = [0]

visited = ["False"] * N

while stack:

 ne = stack.pop()

 if visited[ne] == "False":

  visited[ne] = "True"

  for j in ki[ne]:

   if visited[j] == "False":

    ans[j]+=ans[ne]

    stack.append(j)

L=[str(a) for a in ans]

L=' '.join(L)

print(L)
import sys

input = sys.stdin.readline

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

ans=[0]*N

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

for i in range(N-1):

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

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

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

for i in range(Q):

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

 ans[p-1]+=q

# dfs

stack = [0]

visited = ["False"] * N

while stack:

 ne = stack.pop()

 if visited[ne] == "False":

  visited[ne] = "True"

  for j in ki[ne]:

   if visited[j] == "False":

    ans[j]+=ans[ne]

    stack.append(j)

L=[str(a) for a in ans]

L=' '.join(L)

print(L)
N, Q = list(map(int, input().split()))
ans = [0] * N
ki = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    ki[a - 1].append(b - 1)
    ki[b - 1].append(a - 1)
for i in range(Q):
    p, q = list(map(int, input().split()))
    ans[p - 1] += q
# dfs
stack = [0]
visited = ["False"] * N
while stack:
    ne = stack.pop()
    if visited[ne] == "False":
        visited[ne] = "True"
        for j in ki[ne]:
            if visited[j] == "False":
                ans[j] += ans[ne]
                stack.append(j)
L = [str(a) for a in ans]
L = " ".join(L)
print(L)

import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
ans = [0] * N
ki = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    ki[a - 1].append(b - 1)
    ki[b - 1].append(a - 1)
for i in range(Q):
    p, q = list(map(int, input().split()))
    ans[p - 1] += q
# dfs
stack = [0]
visited = ["False"] * N
while stack:
    ne = stack.pop()
    if visited[ne] == "False":
        visited[ne] = "True"
        for j in ki[ne]:
            if visited[j] == "False":
                ans[j] += ans[ne]
                stack.append(j)
L = [str(a) for a in ans]
L = " ".join(L)
print(L)

+import sys + +input = sys.stdin.readline