import sys

input=sys.stdin.readline

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

l=[]

for i in range(n-1):

  l.append(list(map(int,input().split())))

l2=[]

for i in range(q):

  l2.append(list(map(int,input().split())))

connection=[]

for i in range(n):

  connection.append([])

for i in range(n-1):

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

 

L4=[]

for i in range(n):

  L4.append(0)

for i in range(q):

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

distance=[]

for i in range(n):

  distance.append(0)

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

  distance[i]=str(distance[i])

print((' '.join(distance)))
import sys

input=sys.stdin.readline

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

l=[]

for i in range(n-1):

  l.append(list(map(int,input().split())))

l2=[]

for i in range(q):

  l2.append(list(map(int,input().split())))

connection=[]

for i in range(n):

  connection.append([])

for i in range(n-1):

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

 

L4=[0]*n

for i in range(q):

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

distance=[0]*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)):

  distance[i]=str(distance[i])

print((' '.join(distance)))
import sys

input = sys.stdin.readline
n, q = list(map(int, input().split()))
l = []
for i in range(n - 1):
    l.append(list(map(int, input().split())))
l2 = []
for i in range(q):
    l2.append(list(map(int, input().split())))
connection = []
for i in range(n):
    connection.append([])
for i in range(n - 1):
    connection[l[i][0] - 1].append(l[i][1] - 1)
L4 = []
for i in range(n):
    L4.append(0)
for i in range(q):
    L4[l2[i][0] - 1] += l2[i][1]
distance = []
for i in range(n):
    distance.append(0)
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)):
    distance[i] = str(distance[i])
print((" ".join(distance)))

import sys

input = sys.stdin.readline
n, q = list(map(int, input().split()))
l = []
for i in range(n - 1):
    l.append(list(map(int, input().split())))
l2 = []
for i in range(q):
    l2.append(list(map(int, input().split())))
connection = []
for i in range(n):
    connection.append([])
for i in range(n - 1):
    connection[l[i][0] - 1].append(l[i][1] - 1)
L4 = [0] * n
for i in range(q):
    L4[l2[i][0] - 1] += l2[i][1]
distance = [0] * 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)):
    distance[i] = str(distance[i])
print((" ".join(distance)))

-L4 = [] -for i in range(n): -    L4.append(0) +L4 = [0] * n -distance = [] -for i in range(n): -    distance.append(0) +distance = [0] * n