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

way = [[] for _ in range(n)]

for i in range(n-1):

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

    way[a-1].append(b-1)

    way[b-1].append(a-1)

add = [0]*n

for i in range(q):

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

    add[a-1] += b

ans = [-1]*n

ans[0] = add[0]

    

stack = [(0,add[0])]

while stack:

    a,b = stack.pop()

    for i in range(len(way[a])):

        if (ans[way[a][i]]==-1):

            stack.append((way[a][i],b+add[way[a][i]]))

            ans[way[a][i]] = b+add[way[a][i]]

print((*ans))
import sys

input = sys.stdin.readline



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

way = [[] for _ in range(n)]

for i in range(n-1):

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

    way[a-1].append(b-1)

    way[b-1].append(a-1)

add = [0]*n

for i in range(q):

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

    add[a-1] += b

ans = [-1]*n

ans[0] = add[0]

    

stack = [(0,add[0])]

while stack:

    a,b = stack.pop()

    for i in range(len(way[a])):

        if (ans[way[a][i]]==-1):

            stack.append((way[a][i],b+add[way[a][i]]))

            ans[way[a][i]] = b+add[way[a][i]]

print((*ans))

    
n, q = list(map(int, input().split()))
way = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    way[a - 1].append(b - 1)
    way[b - 1].append(a - 1)
add = [0] * n
for i in range(q):
    a, b = list(map(int, input().split()))
    add[a - 1] += b
ans = [-1] * n
ans[0] = add[0]
stack = [(0, add[0])]
while stack:
    a, b = stack.pop()
    for i in range(len(way[a])):
        if ans[way[a][i]] == -1:
            stack.append((way[a][i], b + add[way[a][i]]))
            ans[way[a][i]] = b + add[way[a][i]]
print((*ans))

import sys

input = sys.stdin.readline
n, q = list(map(int, input().split()))
way = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    way[a - 1].append(b - 1)
    way[b - 1].append(a - 1)
add = [0] * n
for i in range(q):
    a, b = list(map(int, input().split()))
    add[a - 1] += b
ans = [-1] * n
ans[0] = add[0]
stack = [(0, add[0])]
while stack:
    a, b = stack.pop()
    for i in range(len(way[a])):
        if ans[way[a][i]] == -1:
            stack.append((way[a][i], b + add[way[a][i]]))
            ans[way[a][i]] = b + add[way[a][i]]
print((*ans))

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