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 sys

 

read = sys.stdin.buffer.read

input = sys.stdin.buffer.readline

inputs = sys.stdin.buffer.readlines





from collections import deque



def main():



  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:]))

      

if __name__ == "__main__":

  main()     
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 sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines
from collections import deque


def main():
    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:]))


if __name__ == "__main__":
    main()

+import sys + +read = sys.stdin.buffer.read +input = sys.stdin.buffer.readline +inputs = sys.stdin.buffer.readlines -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:])) + +def main(): +    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:])) + + +if __name__ == "__main__": +    main()