import sys

input = sys.stdin.readline #for input speed

sys.setrecursionlimit(10**6)



def DFS(v, parent):

  global v_count

  for u in adj[v]:

    if u != parent:

      v_count[u] += v_count[v]

      DFS(u,v)



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



adj = [[] for _ in range(N)]

v_count = [0] * N



for i in range(N-1):

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

  a -= 1

  b -= 1

  adj[a].append(b)

  adj[b].append(a)# aがbの親とは限らないため



for j in range(Q):

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

  v_count[p-1] += x



# 0起点に親ノードの数字を子ノードに足していく

DFS(0, -1)# 現在のノード, 親ノード

print((*v_count))

from collections import deque



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

adj = [[] for _ in range(N)]

count = [0] * N



for _ in range(N-1):

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

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

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

  

for _ in range(Q):

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

  count[p-1] += x



queue = deque([0])

visit = [True] * N

visit[0] = False



while queue:

  now = queue.popleft()

  for u in adj[now]:

    if visit[u]:

      count[u] += count[now]

      queue.append(u)

      visit[u] = False

print((*count))
import sys

input = sys.stdin.readline  # for input speed
sys.setrecursionlimit(10**6)


def DFS(v, parent):
    global v_count
    for u in adj[v]:
        if u != parent:
            v_count[u] += v_count[v]
            DFS(u, v)


N, Q = list(map(int, input().split()))
adj = [[] for _ in range(N)]
v_count = [0] * N
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)  # aがbの親とは限らないため
for j in range(Q):
    p, x = list(map(int, input().split()))
    v_count[p - 1] += x
# 0起点に親ノードの数字を子ノードに足していく
DFS(0, -1)  # 現在のノード, 親ノード
print((*v_count))

from collections import deque

N, Q = list(map(int, input().split()))
adj = [[] for _ in range(N)]
count = [0] * N
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    adj[a - 1].append(b - 1)
    adj[b - 1].append(a - 1)
for _ in range(Q):
    p, x = list(map(int, input().split()))
    count[p - 1] += x
queue = deque([0])
visit = [True] * N
visit[0] = False
while queue:
    now = queue.popleft()
    for u in adj[now]:
        if visit[u]:
            count[u] += count[now]
            queue.append(u)
            visit[u] = False
print((*count))

-import sys - -input = sys.stdin.readline  # for input speed -sys.setrecursionlimit(10**6) - - -def DFS(v, parent): -    global v_count -    for u in adj[v]: -        if u != parent: -            v_count[u] += v_count[v] -            DFS(u, v) - +from collections import deque -v_count = [0] * N -for i in range(N - 1): +count = [0] * N +for _ in range(N - 1): -    a -= 1 -    b -= 1 -    adj[a].append(b) -    adj[b].append(a)  # aがbの親とは限らないため -for j in range(Q): +    adj[a - 1].append(b - 1) +    adj[b - 1].append(a - 1) +for _ in range(Q): -    v_count[p - 1] += x -# 0起点に親ノードの数字を子ノードに足していく -DFS(0, -1)  # 現在のノード, 親ノード -print((*v_count)) +    count[p - 1] += x +queue = deque([0]) +visit = [True] * N +visit[0] = False +while queue: +    now = queue.popleft() +    for u in adj[now]: +        if visit[u]: +            count[u] += count[now] +            queue.append(u) +            visit[u] = False +print((*count))