import sys

from collections import deque

input = sys.stdin.readline



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

score = [0]*(n+1)

tree = [[] for i in range(n+1)]

check = [0]*(n+1)

check[1] = 1



for i in range(n-1):

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

  tree[b] += [a]

  tree[a] += [b]



que = deque([1])

qappend = que.append

qpop = que.pop



for i in range(q):

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

  score[q] += x



while que:

  n = qpop()

  for i in tree[n]:

    if check[i]:continue

    check[i] = 1

    score[i] += score[n]

    qappend(i)



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

from collections import deque

input = sys.stdin.readline



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

score = [0]*(n+1)

tree = [[] for i in range(n+1)]

check = [0]*(n+1)

check[1] = 1



for i in range(n-1):

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

  tree[b] += [a]

  tree[a] += [b]



que = deque([1])

qappend = que.append

qpop = que.pop



for i in range(q):

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

  score[q] += x



while que:

  n = qpop()

  for i in tree[n]:

    if check[i]:continue

    check[i] = 1

    score[i] += score[n]

    qappend(i)



print((" ".join(map(str, score[1:]))))
import sys
from collections import deque

input = sys.stdin.readline
n, q = list(map(int, input().split()))
score = [0] * (n + 1)
tree = [[] for i in range(n + 1)]
check = [0] * (n + 1)
check[1] = 1
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    tree[b] += [a]
    tree[a] += [b]
que = deque([1])
qappend = que.append
qpop = que.pop
for i in range(q):
    q, x = list(map(int, input().split()))
    score[q] += x
while que:
    n = qpop()
    for i in tree[n]:
        if check[i]:
            continue
        check[i] = 1
        score[i] += score[n]
        qappend(i)
print((*score[1:]))

import sys
from collections import deque

input = sys.stdin.readline
n, q = list(map(int, input().split()))
score = [0] * (n + 1)
tree = [[] for i in range(n + 1)]
check = [0] * (n + 1)
check[1] = 1
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    tree[b] += [a]
    tree[a] += [b]
que = deque([1])
qappend = que.append
qpop = que.pop
for i in range(q):
    q, x = list(map(int, input().split()))
    score[q] += x
while que:
    n = qpop()
    for i in tree[n]:
        if check[i]:
            continue
        check[i] = 1
        score[i] += score[n]
        qappend(i)
print((" ".join(map(str, score[1:]))))

-print((*score[1:])) +print((" ".join(map(str, score[1:]))))