N,Q=list(map(int,input().split()))

L=[[]for i in range(N+1)]

for i in range(N-1):

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

    L[a].append(b)

    L[b].append(a)

    

S=[0 for i in range(N+1)]

for i in range(Q):

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

    S[p]+=x

    

ANS=[-1 for i in range(N+1)]

ANS[1]=S[1]

l=[]

for i in L[1]:

    l.append([i,1,S[1]])

    

for i in range(N-1):

    X=l[i][0]

    Y=l[i][1]

    Z=l[i][2]

    ANS[X]=Z+S[X]

    for j in L[X]:

        if ANS[j]<0:

            l.append([j,X,ANS[X]])

print((*ANS[1:]))

        

    
import sys

input=sys.stdin.readline



N,Q=list(map(int,input().split()))

L=[[]for i in range(N+1)]

for i in range(N-1):

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

    L[a].append(b)

    L[b].append(a)

    

S=[0 for i in range(N+1)]

for i in range(Q):

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

    S[p]+=x

    

ANS=[-1 for i in range(N+1)]

ANS[1]=S[1]

l=[]

for i in L[1]:

    l.append([i,1,S[1]])

    

for i in range(N-1):

    X=l[i][0]

    Y=l[i][1]

    Z=l[i][2]

    ANS[X]=Z+S[X]

    for j in L[X]:

        if ANS[j]<0:

            l.append([j,X,ANS[X]])

print((*ANS[1:]))

        

    
N, Q = list(map(int, input().split()))
L = [[] for i in range(N + 1)]
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    L[a].append(b)
    L[b].append(a)
S = [0 for i in range(N + 1)]
for i in range(Q):
    p, x = list(map(int, input().split()))
    S[p] += x
ANS = [-1 for i in range(N + 1)]
ANS[1] = S[1]
l = []
for i in L[1]:
    l.append([i, 1, S[1]])
for i in range(N - 1):
    X = l[i][0]
    Y = l[i][1]
    Z = l[i][2]
    ANS[X] = Z + S[X]
    for j in L[X]:
        if ANS[j] < 0:
            l.append([j, X, ANS[X]])
print((*ANS[1:]))

import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
L = [[] for i in range(N + 1)]
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    L[a].append(b)
    L[b].append(a)
S = [0 for i in range(N + 1)]
for i in range(Q):
    p, x = list(map(int, input().split()))
    S[p] += x
ANS = [-1 for i in range(N + 1)]
ANS[1] = S[1]
l = []
for i in L[1]:
    l.append([i, 1, S[1]])
for i in range(N - 1):
    X = l[i][0]
    Y = l[i][1]
    Z = l[i][2]
    ANS[X] = Z + S[X]
    for j in L[X]:
        if ANS[j] < 0:
            l.append([j, X, ANS[X]])
print((*ANS[1:]))

+import sys + +input = sys.stdin.readline