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



ct = [0] * (n+1)

o = [0] * (n+1)

g = [[] for _ in range(n+1)]



for i in range(n-1):

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

  g[a].append(b)

  g[b].append(a)



for i in range(q):

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

  o[p] += x



todo = [1]

seen = [False] * (n+1)

while todo:

  p = todo.pop(-1)

  ct[p] += o[p]

  seen[p] = True

  for i in g[p]:

    if seen[i]:

      ct[p] += ct[i]

    else:

      todo.append(i)



print((*ct[1:]))

import sys

input = sys.stdin.readline

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



ct = [0] * (n+1)

o = [0] * (n+1)

g = [[] for _ in range(n+1)]



for i in range(n-1):

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

  g[a].append(b)

  g[b].append(a)



for i in range(q):

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

  o[p] += x



todo = [1]

seen = [False] * (n+1)

while todo:

  p = todo.pop(-1)

  ct[p] += o[p]

  seen[p] = True

  for i in g[p]:

    if seen[i]:

      ct[p] += ct[i]

    else:

      todo.append(i)



print((*ct[1:]))



n, q = list(map(int, input().split()))
ct = [0] * (n + 1)
o = [0] * (n + 1)
g = [[] for _ in range(n + 1)]
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    g[a].append(b)
    g[b].append(a)
for i in range(q):
    p, x = list(map(int, input().split()))
    o[p] += x
todo = [1]
seen = [False] * (n + 1)
while todo:
    p = todo.pop(-1)
    ct[p] += o[p]
    seen[p] = True
    for i in g[p]:
        if seen[i]:
            ct[p] += ct[i]
        else:
            todo.append(i)
print((*ct[1:]))

import sys

input = sys.stdin.readline
n, q = list(map(int, input().split()))
ct = [0] * (n + 1)
o = [0] * (n + 1)
g = [[] for _ in range(n + 1)]
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    g[a].append(b)
    g[b].append(a)
for i in range(q):
    p, x = list(map(int, input().split()))
    o[p] += x
todo = [1]
seen = [False] * (n + 1)
while todo:
    p = todo.pop(-1)
    ct[p] += o[p]
    seen[p] = True
    for i in g[p]:
        if seen[i]:
            ct[p] += ct[i]
        else:
            todo.append(i)
print((*ct[1:]))

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