from collections import deque

import sys

input = sys.stdin.readline



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

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

for _ in range(N - 1):

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

    edge[a].append(b)

    edge[b].append(a)

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



score = [0] * (N + 1)

for n, p in query:

    score[n] += p



seen = [0] * (N + 1)

seen[1] = 1

node = deque([1])

while node:

    s = node.popleft()

    for t in edge[s]:

        if not seen[t]:

            seen[t] = 1

            score[t] += score[s]

            node.append(t)



print((*score[1:]))

import sys

input = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 7)



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

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

for _ in range(N - 1):

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

    edge[a].append(b)

    edge[b].append(a)



dist = [0] * (N + 1)

seen = [False] * (N + 1)

seen[1] = True

node = [1]



for _ in range(Q):

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

    dist[p] += x



while node:

    s = node.pop()

    d = dist[s]

    for t in edge[s]:

        if seen[t]:

            continue

        dist[t] += d

        seen[t] = True

        node.append(t)



print((*dist[1:]))
from collections import deque
import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    edge[a].append(b)
    edge[b].append(a)
query = [list(map(int, input().split())) for _ in range(Q)]
score = [0] * (N + 1)
for n, p in query:
    score[n] += p
seen = [0] * (N + 1)
seen[1] = 1
node = deque([1])
while node:
    s = node.popleft()
    for t in edge[s]:
        if not seen[t]:
            seen[t] = 1
            score[t] += score[s]
            node.append(t)
print((*score[1:]))

import sys

input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
N, Q = list(map(int, input().split()))
edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    edge[a].append(b)
    edge[b].append(a)
dist = [0] * (N + 1)
seen = [False] * (N + 1)
seen[1] = True
node = [1]
for _ in range(Q):
    p, x = list(map(int, input().split()))
    dist[p] += x
while node:
    s = node.pop()
    d = dist[s]
    for t in edge[s]:
        if seen[t]:
            continue
        dist[t] += d
        seen[t] = True
        node.append(t)
print((*dist[1:]))

-from collections import deque -input = sys.stdin.readline +input = sys.stdin.buffer.readline +sys.setrecursionlimit(10**7) -query = [list(map(int, input().split())) for _ in range(Q)] -score = [0] * (N + 1) -for n, p in query: -    score[n] += p -seen = [0] * (N + 1) -seen[1] = 1 -node = deque([1]) +dist = [0] * (N + 1) +seen = [False] * (N + 1) +seen[1] = True +node = [1] +for _ in range(Q): +    p, x = list(map(int, input().split())) +    dist[p] += x -    s = node.popleft() +    s = node.pop() +    d = dist[s] -        if not seen[t]: -            seen[t] = 1 -            score[t] += score[s] -            node.append(t) -print((*score[1:])) +        if seen[t]: +            continue +        dist[t] += d +        seen[t] = True +        node.append(t) +print((*dist[1:]))