import sys

readline = sys.stdin.readline



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

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

for i in range(N - 1):

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

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

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



P = [0 for i in range(N)]

for i in range(Q):

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

  P[p - 1] += x

  

stack = [[0, 0, -1]]

while stack:

  v,point,parent = stack.pop()

  P[v] += point

  for child in G[v]:

    if child == parent:

      continue

    stack.append([child,P[v],v])

  

print((*P))
import sys

readline = sys.stdin.readline



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



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

for i in range(N - 1):

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

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

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



P = [0] * N

for i in range(Q):

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

  P[p - 1] += x

  

ans = [0] * N



stack = []

# 頂点, 親, そこまでの点数

stack.append([0, -1, 0])

while stack:

  v,parent,point = stack.pop()

  point += P[v]

  ans[v] = point

  for child in G[v]:

    if child == parent:

      continue

    stack.append([child, v, point])

  

print((*ans))
import sys

readline = sys.stdin.readline
N, Q = list(map(int, readline().split()))
G = [[] for i in range(N)]
for i in range(N - 1):
    a, b = list(map(int, readline().split()))
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
P = [0 for i in range(N)]
for i in range(Q):
    p, x = list(map(int, readline().split()))
    P[p - 1] += x
stack = [[0, 0, -1]]
while stack:
    v, point, parent = stack.pop()
    P[v] += point
    for child in G[v]:
        if child == parent:
            continue
        stack.append([child, P[v], v])
print((*P))

import sys

readline = sys.stdin.readline
N, Q = list(map(int, readline().split()))
G = [[] for i in range(N)]
for i in range(N - 1):
    a, b = list(map(int, readline().split()))
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
P = [0] * N
for i in range(Q):
    p, x = list(map(int, readline().split()))
    P[p - 1] += x
ans = [0] * N
stack = []
# 頂点, 親, そこまでの点数
stack.append([0, -1, 0])
while stack:
    v, parent, point = stack.pop()
    point += P[v]
    ans[v] = point
    for child in G[v]:
        if child == parent:
            continue
        stack.append([child, v, point])
print((*ans))

-P = [0 for i in range(N)] +P = [0] * N -stack = [[0, 0, -1]] +ans = [0] * N +stack = [] +# 頂点, 親, そこまでの点数 +stack.append([0, -1, 0]) -    v, point, parent = stack.pop() -    P[v] += point +    v, parent, point = stack.pop() +    point += P[v] +    ans[v] = point -        stack.append([child, P[v], v]) -print((*P)) +        stack.append([child, v, point]) +print((*ans))