import sys

readline = sys.stdin.readline

readlines = sys.stdin.readlines



# 遅延評価で加えてあげるだけ



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

AB = (tuple(int(x) for x in readline().split()) for _ in range(N-1))

PX = (tuple(int(x) for x in readline().split()) for _ in range(Q))



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

for a,b in AB:

    graph[a].append(b)

    graph[b].append(a)



value = [0] * (N+1)

for p,x in PX:

    value[p] += x



par = [None] * (N+1)

q = [1]

while q:

    x = q.pop()

    for y in graph[x]:

        if y == par[x]:

            continue

        value[y] += value[x]

        q.append(y)

        par[y] = x



answer = ' '.join(map(str,value[1:]))

print(answer)

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



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

ABPX = list(map(int,read().split()))

AB = iter(ABPX[:N+N-2])

PX = iter(ABPX[N+N-2:])



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

for a,b in zip(AB,AB):

    graph[a].append(b)

    graph[b].append(a)



val = [0] * (N+1)

for p,x in zip(PX,PX):

    val[p] += x



stack = [1]

parent = [0] * (N+1)

while stack:

    x = stack.pop()

    for y in graph[x]:

        if y == parent[x]:

            continue

        parent[y] = x

        stack.append(y)

        val[y] += val[x]



print((' '.join(map(str,val[1:]))))
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
# 遅延評価で加えてあげるだけ
N, Q = list(map(int, readline().split()))
AB = (tuple(int(x) for x in readline().split()) for _ in range(N - 1))
PX = (tuple(int(x) for x in readline().split()) for _ in range(Q))
graph = [[] for _ in range(N + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)
value = [0] * (N + 1)
for p, x in PX:
    value[p] += x
par = [None] * (N + 1)
q = [1]
while q:
    x = q.pop()
    for y in graph[x]:
        if y == par[x]:
            continue
        value[y] += value[x]
        q.append(y)
        par[y] = x
answer = " ".join(map(str, value[1:]))
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, Q = list(map(int, readline().split()))
ABPX = list(map(int, read().split()))
AB = iter(ABPX[: N + N - 2])
PX = iter(ABPX[N + N - 2 :])
graph = [[] for _ in range(N + 1)]
for a, b in zip(AB, AB):
    graph[a].append(b)
    graph[b].append(a)
val = [0] * (N + 1)
for p, x in zip(PX, PX):
    val[p] += x
stack = [1]
parent = [0] * (N + 1)
while stack:
    x = stack.pop()
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)
        val[y] += val[x]
print((" ".join(map(str, val[1:]))))

-readline = sys.stdin.readline -readlines = sys.stdin.readlines -# 遅延評価で加えてあげるだけ +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines -AB = (tuple(int(x) for x in readline().split()) for _ in range(N - 1)) -PX = (tuple(int(x) for x in readline().split()) for _ in range(Q)) +ABPX = list(map(int, read().split())) +AB = iter(ABPX[: N + N - 2]) +PX = iter(ABPX[N + N - 2 :]) -for a, b in AB: +for a, b in zip(AB, AB): -value = [0] * (N + 1) -for p, x in PX: -    value[p] += x -par = [None] * (N + 1) -q = [1] -while q: -    x = q.pop() +val = [0] * (N + 1) +for p, x in zip(PX, PX): +    val[p] += x +stack = [1] +parent = [0] * (N + 1) +while stack: +    x = stack.pop() -        if y == par[x]: +        if y == parent[x]: -        value[y] += value[x] -        q.append(y) -        par[y] = x -answer = " ".join(map(str, value[1:])) -print(answer) +        parent[y] = x +        stack.append(y) +        val[y] += val[x] +print((" ".join(map(str, val[1:]))))