import sys

input=sys.stdin.readline

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

l=[list(map(int,input().split())) for i in range(n-1)]

l2=[list(map(int,input().split())) for i in range(q)]

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

for i in range(n-1):

  connection[l[i][0]-1].append(l[i][1]-1)

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

for i in range(q):

  L4[l2[i][0]-1]+=l2[i][1]

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

distance[0]=L4[0]



L=[0]

L2=[]

L3=[]

while len(L2)!=n and len(L)!=0:

  for j in range(len(L)):

    for k in range(len(connection[L[j]])):

      distance[connection[L[j]][k]]=distance[L[j]]+L4[connection[L[j]][k]]

      L3.append(connection[L[j]][k])

    L2.append(L[j])

  L=L3

  L3=[]

for i in range(len(distance)):

  print((distance[i]))
import sys

input=sys.stdin.readline

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

l=[list(map(int,input().split())) for i in range(n-1)]

l2=[list(map(int,input().split())) for i in range(q)]

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

for i in range(n-1):

  connection[l[i][0]-1].append(l[i][1]-1)

  connection[l[i][1]-1].append(l[i][0]-1)

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

for i in range(q):

  L4[l2[i][0]-1]+=l2[i][1]

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

distance[0]=L4[0]



L=[0]

L2=[]

L22=[-1]*n

L3=[]

while len(L2)!=n and len(L)!=0:

  for j in range(len(L)):

    L22[L[j]]=1

    for k in range(len(connection[L[j]])):

      if L22[connection[L[j]][k]]==-1:

        distance[connection[L[j]][k]]=distance[L[j]]+L4[connection[L[j]][k]]

        L3.append(connection[L[j]][k])

  L=L3

  L3=[]

for i in range(len(distance)):

  print((distance[i]))
import sys

input = sys.stdin.readline
n, q = list(map(int, input().split()))
l = [list(map(int, input().split())) for i in range(n - 1)]
l2 = [list(map(int, input().split())) for i in range(q)]
connection = [[] for i in range(n)]
for i in range(n - 1):
    connection[l[i][0] - 1].append(l[i][1] - 1)
L4 = [0 for i in range(n)]
for i in range(q):
    L4[l2[i][0] - 1] += l2[i][1]
distance = [0 for i in range(n)]
distance[0] = L4[0]
L = [0]
L2 = []
L3 = []
while len(L2) != n and len(L) != 0:
    for j in range(len(L)):
        for k in range(len(connection[L[j]])):
            distance[connection[L[j]][k]] = distance[L[j]] + L4[connection[L[j]][k]]
            L3.append(connection[L[j]][k])
        L2.append(L[j])
    L = L3
    L3 = []
for i in range(len(distance)):
    print((distance[i]))

import sys

input = sys.stdin.readline
n, q = list(map(int, input().split()))
l = [list(map(int, input().split())) for i in range(n - 1)]
l2 = [list(map(int, input().split())) for i in range(q)]
connection = [[] for i in range(n)]
for i in range(n - 1):
    connection[l[i][0] - 1].append(l[i][1] - 1)
    connection[l[i][1] - 1].append(l[i][0] - 1)
L4 = [0 for i in range(n)]
for i in range(q):
    L4[l2[i][0] - 1] += l2[i][1]
distance = [0 for i in range(n)]
distance[0] = L4[0]
L = [0]
L2 = []
L22 = [-1] * n
L3 = []
while len(L2) != n and len(L) != 0:
    for j in range(len(L)):
        L22[L[j]] = 1
        for k in range(len(connection[L[j]])):
            if L22[connection[L[j]][k]] == -1:
                distance[connection[L[j]][k]] = distance[L[j]] + L4[connection[L[j]][k]]
                L3.append(connection[L[j]][k])
    L = L3
    L3 = []
for i in range(len(distance)):
    print((distance[i]))

+    connection[l[i][1] - 1].append(l[i][0] - 1) +L22 = [-1] * n +        L22[L[j]] = 1 -            distance[connection[L[j]][k]] = distance[L[j]] + L4[connection[L[j]][k]] -            L3.append(connection[L[j]][k]) -        L2.append(L[j]) +            if L22[connection[L[j]][k]] == -1: +                distance[connection[L[j]][k]] = distance[L[j]] + L4[connection[L[j]][k]] +                L3.append(connection[L[j]][k])