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

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

PX = [list(map(int, 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)

graph = tuple(graph)

#print("graph:", graph)

  

X = [0] * (N + 1)

for p, x in PX:

  X[p] += x

#print("X:", X)



stack = [1]

check = [0] * (N + 1)

check[1] = 1

cnt = [0] * (N + 1)

cnt[1] = X[1]



while stack:

  s = stack.pop()

  for g in graph[s]:

    if check[g] == 0:

      check[g] = 1

      cnt[g] = cnt[s] + X[g]

      stack.append(g)

print((*cnt[1::]))
import sys

input = sys.stdin.buffer.readline



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

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

PX = [list(map(int, 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)

  

cost = [0] * (N + 1)

for p, x in PX:

  cost[p] += x

  

check = [0] * (N + 1)

stack = [1]

check[1] = 1



while stack:

  s = stack.pop()

  for g in graph[s]:

    if check[g] == 0:

      check[g] = 1

      cost[g] += cost[s]

      stack.append(g)

      

print((*cost[1:]))
N, Q = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N - 1)]
PX = [list(map(int, 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)
graph = tuple(graph)
# print("graph:", graph)
X = [0] * (N + 1)
for p, x in PX:
    X[p] += x
# print("X:", X)
stack = [1]
check = [0] * (N + 1)
check[1] = 1
cnt = [0] * (N + 1)
cnt[1] = X[1]
while stack:
    s = stack.pop()
    for g in graph[s]:
        if check[g] == 0:
            check[g] = 1
            cnt[g] = cnt[s] + X[g]
            stack.append(g)
print((*cnt[1::]))

import sys

input = sys.stdin.buffer.readline
N, Q = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N - 1)]
PX = [list(map(int, 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)
cost = [0] * (N + 1)
for p, x in PX:
    cost[p] += x
check = [0] * (N + 1)
stack = [1]
check[1] = 1
while stack:
    s = stack.pop()
    for g in graph[s]:
        if check[g] == 0:
            check[g] = 1
            cost[g] += cost[s]
            stack.append(g)
print((*cost[1:]))

+import sys + +input = sys.stdin.buffer.readline -for A, B in AB: -    graph[A].append(B) -    graph[B].append(A) -graph = tuple(graph) -# print("graph:", graph) -X = [0] * (N + 1) +for a, b in AB: +    graph[a].append(b) +    graph[b].append(a) +cost = [0] * (N + 1) -    X[p] += x -# print("X:", X) +    cost[p] += x +check = [0] * (N + 1) -check = [0] * (N + 1) -cnt = [0] * (N + 1) -cnt[1] = X[1] -            cnt[g] = cnt[s] + X[g] +            cost[g] += cost[s] -print((*cnt[1::])) +print((*cost[1:]))