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

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

for i in range(N-1):

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

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

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

X=[0]*N

for i in range(Q):

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

  X[p-1]+=x

  

stack=[]

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

ans=[0]*N

while stack:

  node=stack.pop()

  v=node[0]

  val=node[1]

  parent=node[2]

  ans[v]+=val+X[v]

  children=E[v]

  for child in children:

    if child==parent:

      continue

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



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))
N, Q = list(map(int, input().split()))
E = [[] for i in range(N)]
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    E[a - 1].append(b - 1)
    E[b - 1].append(a - 1)
X = [0] * N
for i in range(Q):
    p, x = list(map(int, input().split()))
    X[p - 1] += x
stack = []
stack.append([0, 0, -1])
ans = [0] * N
while stack:
    node = stack.pop()
    v = node[0]
    val = node[1]
    parent = node[2]
    ans[v] += val + X[v]
    children = E[v]
    for child in children:
        if child == parent:
            continue
        stack.append([child, ans[v], v])
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))

-N, Q = list(map(int, input().split())) -E = [[] for i in range(N)] +import sys + +readline = sys.stdin.readline +N, Q = list(map(int, readline().split())) +G = [[] for i in range(N)] -    a, b = list(map(int, input().split())) -    E[a - 1].append(b - 1) -    E[b - 1].append(a - 1) -X = [0] * N +    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)] -    p, x = list(map(int, input().split())) -    X[p - 1] += x -stack = [] -stack.append([0, 0, -1]) -ans = [0] * N +    p, x = list(map(int, readline().split())) +    P[p - 1] += x +stack = [[0, 0, -1]] -    node = stack.pop() -    v = node[0] -    val = node[1] -    parent = node[2] -    ans[v] += val + X[v] -    children = E[v] -    for child in children: +    v, point, parent = stack.pop() +    P[v] += point +    for child in G[v]: -        stack.append([child, ans[v], v]) -print((*ans)) +        stack.append([child, P[v], v]) +print((*P))