from collections import defaultdict

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



d = defaultdict(list)

for _ in range(N-1):

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

    d[a].append(b)

    d[b].append(a)



dp = [0]*N

used = [False]*N



for _ in range(Q):

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

    dp[p-1] += x



q = [1]

used[0] = True



while q:

    x = q.pop()

    

    for i in d[x]:

        if used[i-1]==True:

            continue

        dp[i-1] += dp[x-1]

        used[i-1] = True

        q.append(i)



print((*dp))
from collections import defaultdict



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

d = defaultdict(list)

for _ in range(N-1):

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

    d[a].append(b)

    d[b].append(a)

ans = [0]*(N+1)

for _ in range(Q):

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

    ans[p] += x



q = [1]

used = [False]*(N+1)

used[1] = True

while q:

    s = q.pop()

    for t in d[s]:

        if used[t]:continue

        used[t] = True

        ans[t]+=ans[s]

        q.append(t)



print((*ans[1:]))
from collections import defaultdict

N, Q = list(map(int, input().split()))
d = defaultdict(list)
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    d[a].append(b)
    d[b].append(a)
dp = [0] * N
used = [False] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    dp[p - 1] += x
q = [1]
used[0] = True
while q:
    x = q.pop()
    for i in d[x]:
        if used[i - 1] == True:
            continue
        dp[i - 1] += dp[x - 1]
        used[i - 1] = True
        q.append(i)
print((*dp))

from collections import defaultdict

N, Q = list(map(int, input().split()))
d = defaultdict(list)
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    d[a].append(b)
    d[b].append(a)
ans = [0] * (N + 1)
for _ in range(Q):
    p, x = list(map(int, input().split()))
    ans[p] += x
q = [1]
used = [False] * (N + 1)
used[1] = True
while q:
    s = q.pop()
    for t in d[s]:
        if used[t]:
            continue
        used[t] = True
        ans[t] += ans[s]
        q.append(t)
print((*ans[1:]))

-dp = [0] * N -used = [False] * N +ans = [0] * (N + 1) -    dp[p - 1] += x +    ans[p] += x -used[0] = True +used = [False] * (N + 1) +used[1] = True -    x = q.pop() -    for i in d[x]: -        if used[i - 1] == True: +    s = q.pop() +    for t in d[s]: +        if used[t]: -        dp[i - 1] += dp[x - 1] -        used[i - 1] = True -        q.append(i) -print((*dp)) +        used[t] = True +        ans[t] += ans[s] +        q.append(t) +print((*ans[1:]))