import collections



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

a=sorted(list(list(map(int,input().split())) for i in range(n-1)))

p=collections.defaultdict(int)

for i in range(q):

  k,v=list(map(int,input().split()))

  p[k]+=v



li=[0]*n

li[0]+=p[1]

for i in range(n-1):

  li[a[i][1]-1]+=li[a[i][0]-1]+p[a[i][1]]

print((*li))
from collections import deque



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



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

ans=[0]*(n+1)



for i in range(n-1):

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

  li[a].append(b)

  li[b].append(a)



for i in range(q):

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

  ans[p]+=x



Q=deque([1])

sumi=set([1])



while Q:

#  print(Q)

  now=Q.pop()

  for i in li[now]:

    if i in sumi:

      continue

    else:

      sumi.add(i)

      Q.append(i)

      ans[i]+=ans[now]

print((*ans[1:]))

import collections

n, q = list(map(int, input().split()))
a = sorted(list(list(map(int, input().split())) for i in range(n - 1)))
p = collections.defaultdict(int)
for i in range(q):
    k, v = list(map(int, input().split()))
    p[k] += v
li = [0] * n
li[0] += p[1]
for i in range(n - 1):
    li[a[i][1] - 1] += li[a[i][0] - 1] + p[a[i][1]]
print((*li))

from collections import deque

n, q = list(map(int, input().split()))
li = [[] for i in range(n + 1)]
ans = [0] * (n + 1)
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    li[a].append(b)
    li[b].append(a)
for i in range(q):
    p, x = list(map(int, input().split()))
    ans[p] += x
Q = deque([1])
sumi = set([1])
while Q:
    #  print(Q)
    now = Q.pop()
    for i in li[now]:
        if i in sumi:
            continue
        else:
            sumi.add(i)
            Q.append(i)
            ans[i] += ans[now]
print((*ans[1:]))

-import collections +from collections import deque -a = sorted(list(list(map(int, input().split())) for i in range(n - 1))) -p = collections.defaultdict(int) +li = [[] for i in range(n + 1)] +ans = [0] * (n + 1) +for i in range(n - 1): +    a, b = list(map(int, input().split())) +    li[a].append(b) +    li[b].append(a) -    k, v = list(map(int, input().split())) -    p[k] += v -li = [0] * n -li[0] += p[1] -for i in range(n - 1): -    li[a[i][1] - 1] += li[a[i][0] - 1] + p[a[i][1]] -print((*li)) +    p, x = list(map(int, input().split())) +    ans[p] += x +Q = deque([1]) +sumi = set([1]) +while Q: +    #  print(Q) +    now = Q.pop() +    for i in li[now]: +        if i in sumi: +            continue +        else: +            sumi.add(i) +            Q.append(i) +            ans[i] += ans[now] +print((*ans[1:]))