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



links = [[] for x in range(n + 1)]

sums = [0 for x in range(n + 1)]

adds = [0 for x in range(n + 1)]



links[0].append(1)



buf = [list(map(int, input().split())) for _ in range(n - 1)]



for link in buf:

  a, b= link

  links[a].append(b)

  links[b].append(a)





buf = [list(map(int, input().split())) for _ in range(m)]

for px in buf:

  p, x = px

  adds[p] += x



que = [0,[1]]

checked = [0 for x in range(n+1)]



que = [[-1, [0]]]



while que:

  link = que.pop()

  par = link[0]

  childs = link[1]



  for child in childs:

    if checked[child] != 1:

      sums[child] = sums[par] + adds[child]

      que.append([child, links[child]])

      checked[child] = 1



  

print((*sums[1:]))
import sys



input = sys.stdin.readline



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



links = [[] for x in range(n + 1)]

sums = [0 for x in range(n + 1)]

adds = [0 for x in range(n + 1)]



links[0].append(1)



buf = [list(map(int, input().split())) for _ in range(n - 1)]



for link in buf:

  a, b= link

  links[a].append(b)

  links[b].append(a)





buf = [list(map(int, input().split())) for _ in range(m)]

for px in buf:

  p, x = px

  adds[p] += x



que = [0,[1]]

checked = [0 for x in range(n+1)]



que = [[-1, [0]]]



while que:

  link = que.pop()

  par = link[0]

  childs = link[1]



  for child in childs:

    if checked[child] != 1:

      sums[child] = sums[par] + adds[child]

      que.append([child, links[child]])

      checked[child] = 1



  

print((*sums[1:]))
n, m = list(map(int, input().split()))
links = [[] for x in range(n + 1)]
sums = [0 for x in range(n + 1)]
adds = [0 for x in range(n + 1)]
links[0].append(1)
buf = [list(map(int, input().split())) for _ in range(n - 1)]
for link in buf:
    a, b = link
    links[a].append(b)
    links[b].append(a)
buf = [list(map(int, input().split())) for _ in range(m)]
for px in buf:
    p, x = px
    adds[p] += x
que = [0, [1]]
checked = [0 for x in range(n + 1)]
que = [[-1, [0]]]
while que:
    link = que.pop()
    par = link[0]
    childs = link[1]
    for child in childs:
        if checked[child] != 1:
            sums[child] = sums[par] + adds[child]
            que.append([child, links[child]])
            checked[child] = 1
print((*sums[1:]))

import sys

input = sys.stdin.readline
n, m = list(map(int, input().split()))
links = [[] for x in range(n + 1)]
sums = [0 for x in range(n + 1)]
adds = [0 for x in range(n + 1)]
links[0].append(1)
buf = [list(map(int, input().split())) for _ in range(n - 1)]
for link in buf:
    a, b = link
    links[a].append(b)
    links[b].append(a)
buf = [list(map(int, input().split())) for _ in range(m)]
for px in buf:
    p, x = px
    adds[p] += x
que = [0, [1]]
checked = [0 for x in range(n + 1)]
que = [[-1, [0]]]
while que:
    link = que.pop()
    par = link[0]
    childs = link[1]
    for child in childs:
        if checked[child] != 1:
            sums[child] = sums[par] + adds[child]
            que.append([child, links[child]])
            checked[child] = 1
print((*sums[1:]))

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