import sys

readline = sys.stdin.readline

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

T = [set() for _ in range(N)]

for _ in range(N - 1):

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

    T[a - 1].add(b - 1)

    T[b - 1].add(a - 1)



ans = [0] * N

for _ in range(Q):

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

    ans[p - 1] += x



done = set()

for s in range(N):

    if s in done:

        continue

    todo = [s]

    while todo:

        c = todo.pop()

        for n in T[c]:

            if not n in done:

                todo.append(n)

                ans[n] += ans[c]

        done.add(c)



print((" ".join(map(str, ans))))
import sys

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

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

for _ in range(N - 1):

    a, b = list(map(int, sys.stdin.readline().split()))

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

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

X = [0] * N

for _ in range(Q):

    p, x = list(map(int, sys.stdin.readline().split()))

    X[p-1] += x



ans = [0] * N

done = set()

todo = [(0, X[0])]

while todo:

    i, sumx = todo.pop()

    ans[i] = sumx

    done.add(i)

    for ni in G[i]:

        if ni in done:

            continue

        todo.append((ni, sumx + X[ni]))

print((" ".join(map(str, ans))))
import sys

readline = sys.stdin.readline
N, Q = list(map(int, readline().split()))
T = [set() for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, readline().split()))
    T[a - 1].add(b - 1)
    T[b - 1].add(a - 1)
ans = [0] * N
for _ in range(Q):
    p, x = list(map(int, readline().split()))
    ans[p - 1] += x
done = set()
for s in range(N):
    if s in done:
        continue
    todo = [s]
    while todo:
        c = todo.pop()
        for n in T[c]:
            if not n in done:
                todo.append(n)
                ans[n] += ans[c]
        done.add(c)
print((" ".join(map(str, ans))))

import sys

N, Q = list(map(int, input().split()))
G = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, sys.stdin.readline().split()))
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
X = [0] * N
for _ in range(Q):
    p, x = list(map(int, sys.stdin.readline().split()))
    X[p - 1] += x
ans = [0] * N
done = set()
todo = [(0, X[0])]
while todo:
    i, sumx = todo.pop()
    ans[i] = sumx
    done.add(i)
    for ni in G[i]:
        if ni in done:
            continue
        todo.append((ni, sumx + X[ni]))
print((" ".join(map(str, ans))))

-readline = sys.stdin.readline -N, Q = list(map(int, readline().split())) -T = [set() for _ in range(N)] +N, Q = list(map(int, input().split())) +G = [[] for _ in range(N)] -    a, b = list(map(int, readline().split())) -    T[a - 1].add(b - 1) -    T[b - 1].add(a - 1) +    a, b = list(map(int, sys.stdin.readline().split())) +    G[a - 1].append(b - 1) +    G[b - 1].append(a - 1) +X = [0] * N +for _ in range(Q): +    p, x = list(map(int, sys.stdin.readline().split())) +    X[p - 1] += x -for _ in range(Q): -    p, x = list(map(int, readline().split())) -    ans[p - 1] += x -for s in range(N): -    if s in done: -        continue -    todo = [s] -    while todo: -        c = todo.pop() -        for n in T[c]: -            if not n in done: -                todo.append(n) -                ans[n] += ans[c] -        done.add(c) +todo = [(0, X[0])] +while todo: +    i, sumx = todo.pop() +    ans[i] = sumx +    done.add(i) +    for ni in G[i]: +        if ni in done: +            continue +        todo.append((ni, sumx + X[ni]))