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

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

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



graph = [[] for _ in range(N+1)]

for a,b in ab:

    graph[a].append(b)

    graph[b].append(a)

 

value = [0] * (N+1)

for p,x in px:

    value[p] += x

    

q = [(1,0)]

while q:

    x,parent = q.pop()

    value[x] += value[parent]

    for y in graph[x]:

        if y == parent:

            continue

        q.append((y,x))

 

answer = ' '.join(map(str,value[1:]))

print(answer)
import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)

 

# 遅延評価で加えてあげるだけ

 

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

ab = [[int(x) for x in input().split()] for _ in range(N-1)]

px = [[int(x) for x in input().split()] for _ in range(Q)]



graph = [[] for _ in range(N+1)]

for a,b in ab:

    graph[a].append(b)

    graph[b].append(a)

 

value = [0] * (N+1)

for p,x in px:

    value[p] += x

    

q = [(1,0)]

while q:

    x,parent = q.pop()

    value[x] += value[parent]

    for y in graph[x]:

        if y == parent:

            continue

        q.append((y,x))

 

answer = ' '.join(map(str,value[1:]))

print(answer)
N, Q = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(N - 1)]
px = [list(map(int, input().split())) for i in range(Q)]
graph = [[] for _ in range(N + 1)]
for a, b in ab:
    graph[a].append(b)
    graph[b].append(a)
value = [0] * (N + 1)
for p, x in px:
    value[p] += x
q = [(1, 0)]
while q:
    x, parent = q.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        q.append((y, x))
answer = " ".join(map(str, value[1:]))
print(answer)

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
# 遅延評価で加えてあげるだけ
N, Q = list(map(int, input().split()))
ab = [[int(x) for x in input().split()] for _ in range(N - 1)]
px = [[int(x) for x in input().split()] for _ in range(Q)]
graph = [[] for _ in range(N + 1)]
for a, b in ab:
    graph[a].append(b)
    graph[b].append(a)
value = [0] * (N + 1)
for p, x in px:
    value[p] += x
q = [(1, 0)]
while q:
    x, parent = q.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        q.append((y, x))
answer = " ".join(map(str, value[1:]))
print(answer)

+import sys + +input = sys.stdin.readline +sys.setrecursionlimit(10**7) +# 遅延評価で加えてあげるだけ -ab = [list(map(int, input().split())) for i in range(N - 1)] -px = [list(map(int, input().split())) for i in range(Q)] +ab = [[int(x) for x in input().split()] for _ in range(N - 1)] +px = [[int(x) for x in input().split()] for _ in range(Q)]