import sys

sys.setrecursionlimit(10 ** 7)



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



N, Q = lr()

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

for _ in range(N-1):

    a, b = lr()

    edges[a].append(b)

    edges[b].append(a)



counter = [0] * (N+1)

for _ in range(Q):

    p, x = lr()

    counter[p] += x



parents = [0] * (N+1)



def bfs(x):

    p = parents[x]

    c = counter[x]

    for y in edges[x]:

        if y == p:

            continue

        counter[y] += c

        parents[y] = x

        bfs(y)



bfs(1)

print((*counter[1:]))

# 09
import sys



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



# クエリでは根だけにカウンターの値を足して、最後に上から足していく(imos法みたいに)

N, Q = lr()

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

for _ in range(N-1):

    a, b = lr()

    graph[a].append(b)

    graph[b].append(a)



counter = [0] * (N+1) # 1-indexed

for _ in range(Q):

    p, x = lr()

    counter[p] += x



root = 1

stack = [(root, None)]

while stack:

    cur, parent = stack.pop()

    c = counter[cur]

    for child in graph[cur]:

        if child == parent:

            continue

        counter[child] += c

        if len(graph[child]) > 1:

            stack.append((child, cur))



print((*counter[1:]))

import sys

sys.setrecursionlimit(10**7)
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, Q = lr()
edges = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = lr()
    edges[a].append(b)
    edges[b].append(a)
counter = [0] * (N + 1)
for _ in range(Q):
    p, x = lr()
    counter[p] += x
parents = [0] * (N + 1)


def bfs(x):
    p = parents[x]
    c = counter[x]
    for y in edges[x]:
        if y == p:
            continue
        counter[y] += c
        parents[y] = x
        bfs(y)


bfs(1)
print((*counter[1:]))
# 09

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# クエリでは根だけにカウンターの値を足して、最後に上から足していく(imos法みたいに)
N, Q = lr()
graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = lr()
    graph[a].append(b)
    graph[b].append(a)
counter = [0] * (N + 1)  # 1-indexed
for _ in range(Q):
    p, x = lr()
    counter[p] += x
root = 1
stack = [(root, None)]
while stack:
    cur, parent = stack.pop()
    c = counter[cur]
    for child in graph[cur]:
        if child == parent:
            continue
        counter[child] += c
        if len(graph[child]) > 1:
            stack.append((child, cur))
print((*counter[1:]))

-sys.setrecursionlimit(10**7) +# クエリでは根だけにカウンターの値を足して、最後に上から足していく(imos法みたいに) -edges = [[] for _ in range(N + 1)] +graph = [[] for _ in range(N + 1)] -    edges[a].append(b) -    edges[b].append(a) -counter = [0] * (N + 1) +    graph[a].append(b) +    graph[b].append(a) +counter = [0] * (N + 1)  # 1-indexed -parents = [0] * (N + 1) - - -def bfs(x): -    p = parents[x] -    c = counter[x] -    for y in edges[x]: -        if y == p: +root = 1 +stack = [(root, None)] +while stack: +    cur, parent = stack.pop() +    c = counter[cur] +    for child in graph[cur]: +        if child == parent: -        counter[y] += c -        parents[y] = x -        bfs(y) - - -bfs(1) +        counter[child] += c +        if len(graph[child]) > 1: +            stack.append((child, cur)) -# 09