from collections import deque



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



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

for i in range(n-1):

 i,j=list(map(int,input().split()))

 tree[i-1].append(j-1)

 tree[j-1].append(i-1)



cnt=[0 for i in range(n)]

for i in range(q):

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

 cnt[p-1]+=x



seen=set([0])



dq=deque()

dq.append(0)



while dq:

 x=dq.popleft()

 for i in tree[x]:

#  if cnt[i]==-1:

  if i not in seen:

   seen.add(i)

   dq.append(i)

   cnt[i]+=cnt[x]



print((*cnt))
from collections import deque



def main():

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



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

 for i in range(n-1):

  i,j=list(map(int,input().split()))

  tree[i-1].append(j-1)

  tree[j-1].append(i-1)



 cnt=[0 for i in range(n)]

 for i in range(q):

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

  cnt[p-1]+=x



 seen=set([0])



 dq=deque()

 dq.append(0)



 while dq:

  x=dq.popleft()

  for i in tree[x]:

#  if cnt[i]==-1:

   if i not in seen:

    seen.add(i)

    dq.append(i)

    cnt[i]+=cnt[x]



 print((*cnt))



if __name__ == "__main__":

  main()
from collections import deque

n, q = list(map(int, input().split()))
tree = [[] for i in range(n)]
for i in range(n - 1):
    i, j = list(map(int, input().split()))
    tree[i - 1].append(j - 1)
    tree[j - 1].append(i - 1)
cnt = [0 for i in range(n)]
for i in range(q):
    p, x = list(map(int, input().split()))
    cnt[p - 1] += x
seen = set([0])
dq = deque()
dq.append(0)
while dq:
    x = dq.popleft()
    for i in tree[x]:
        #  if cnt[i]==-1:
        if i not in seen:
            seen.add(i)
            dq.append(i)
            cnt[i] += cnt[x]
print((*cnt))

from collections import deque


def main():
    n, q = list(map(int, input().split()))
    tree = [[] for i in range(n)]
    for i in range(n - 1):
        i, j = list(map(int, input().split()))
        tree[i - 1].append(j - 1)
        tree[j - 1].append(i - 1)
    cnt = [0 for i in range(n)]
    for i in range(q):
        p, x = list(map(int, input().split()))
        cnt[p - 1] += x
    seen = set([0])
    dq = deque()
    dq.append(0)
    while dq:
        x = dq.popleft()
        for i in tree[x]:
            #  if cnt[i]==-1:
            if i not in seen:
                seen.add(i)
                dq.append(i)
                cnt[i] += cnt[x]
    print((*cnt))


if __name__ == "__main__":
    main()

-n, q = list(map(int, input().split())) -tree = [[] for i in range(n)] -for i in range(n - 1): -    i, j = list(map(int, input().split())) -    tree[i - 1].append(j - 1) -    tree[j - 1].append(i - 1) -cnt = [0 for i in range(n)] -for i in range(q): -    p, x = list(map(int, input().split())) -    cnt[p - 1] += x -seen = set([0]) -dq = deque() -dq.append(0) -while dq: -    x = dq.popleft() -    for i in tree[x]: -        #  if cnt[i]==-1: -        if i not in seen: -            seen.add(i) -            dq.append(i) -            cnt[i] += cnt[x] -print((*cnt)) + +def main(): +    n, q = list(map(int, input().split())) +    tree = [[] for i in range(n)] +    for i in range(n - 1): +        i, j = list(map(int, input().split())) +        tree[i - 1].append(j - 1) +        tree[j - 1].append(i - 1) +    cnt = [0 for i in range(n)] +    for i in range(q): +        p, x = list(map(int, input().split())) +        cnt[p - 1] += x +    seen = set([0]) +    dq = deque() +    dq.append(0) +    while dq: +        x = dq.popleft() +        for i in tree[x]: +            #  if cnt[i]==-1: +            if i not in seen: +                seen.add(i) +                dq.append(i) +                cnt[i] += cnt[x] +    print((*cnt)) + + +if __name__ == "__main__": +    main()