from collections import deque

import sys

def main():

  a,b=list(map(int,sys.stdin.readline().split()))

  e=[[]for i in range(a)]



  for i in range(a-1):

    c1,c2=list(map(int,sys.stdin.readline().split()))

    e[c1-1].append(c2-1)

    e[c2-1].append(c1-1)



  g=[[]for i in range(a)]

  f=deque([(0,-1)])

  ans=[0 for _ in range(a)]

  for i in range(b):

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

    ans[ten-1]+=p

  i=0

  while len(f)!=0:

    i,fr=f.pop()

    for j in e[i]:

      if j==fr:

        continue

      else:

        ans[j]+=ans[i]

        f.append((j,i)) 

  print((*ans))

if __name__ == '__main__':  

  main()

    

  



  

  

from collections import deque

import sys

input=sys.stdin.readline

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

e=[[]for i in range(a)]



for i in range(a-1):

  c1,c2=list(map(int,input().split()))

  e[c1-1].append(c2-1)

  e[c2-1].append(c1-1)



g=[[]for i in range(a)]

f=deque([(0,-1)])

ans=[0 for _ in range(a)]

for i in range(b):

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

  ans[ten-1]+=p

i=0

while len(f)!=0:

  i,fr=f.pop()

  for j in e[i]:

    if j==fr:

      continue

    else:

      ans[j]+=ans[i]

      f.append((j,i)) 

print((*ans))



    

  



  

  

from collections import deque
import sys


def main():
    a, b = list(map(int, sys.stdin.readline().split()))
    e = [[] for i in range(a)]
    for i in range(a - 1):
        c1, c2 = list(map(int, sys.stdin.readline().split()))
        e[c1 - 1].append(c2 - 1)
        e[c2 - 1].append(c1 - 1)
    g = [[] for i in range(a)]
    f = deque([(0, -1)])
    ans = [0 for _ in range(a)]
    for i in range(b):
        ten, p = list(map(int, input().split()))
        ans[ten - 1] += p
    i = 0
    while len(f) != 0:
        i, fr = f.pop()
        for j in e[i]:
            if j == fr:
                continue
            else:
                ans[j] += ans[i]
                f.append((j, i))
    print((*ans))


if __name__ == "__main__":
    main()

from collections import deque
import sys

input = sys.stdin.readline
a, b = list(map(int, input().split()))
e = [[] for i in range(a)]
for i in range(a - 1):
    c1, c2 = list(map(int, input().split()))
    e[c1 - 1].append(c2 - 1)
    e[c2 - 1].append(c1 - 1)
g = [[] for i in range(a)]
f = deque([(0, -1)])
ans = [0 for _ in range(a)]
for i in range(b):
    ten, p = list(map(int, input().split()))
    ans[ten - 1] += p
i = 0
while len(f) != 0:
    i, fr = f.pop()
    for j in e[i]:
        if j == fr:
            continue
        else:
            ans[j] += ans[i]
            f.append((j, i))
print((*ans))

- -def main(): -    a, b = list(map(int, sys.stdin.readline().split())) -    e = [[] for i in range(a)] -    for i in range(a - 1): -        c1, c2 = list(map(int, sys.stdin.readline().split())) -        e[c1 - 1].append(c2 - 1) -        e[c2 - 1].append(c1 - 1) -    g = [[] for i in range(a)] -    f = deque([(0, -1)]) -    ans = [0 for _ in range(a)] -    for i in range(b): -        ten, p = list(map(int, input().split())) -        ans[ten - 1] += p -    i = 0 -    while len(f) != 0: -        i, fr = f.pop() -        for j in e[i]: -            if j == fr: -                continue -            else: -                ans[j] += ans[i] -                f.append((j, i)) -    print((*ans)) - - -if __name__ == "__main__": -    main() +input = sys.stdin.readline +a, b = list(map(int, input().split())) +e = [[] for i in range(a)] +for i in range(a - 1): +    c1, c2 = list(map(int, input().split())) +    e[c1 - 1].append(c2 - 1) +    e[c2 - 1].append(c1 - 1) +g = [[] for i in range(a)] +f = deque([(0, -1)]) +ans = [0 for _ in range(a)] +for i in range(b): +    ten, p = list(map(int, input().split())) +    ans[ten - 1] += p +i = 0 +while len(f) != 0: +    i, fr = f.pop() +    for j in e[i]: +        if j == fr: +            continue +        else: +            ans[j] += ans[i] +            f.append((j, i)) +print((*ans))