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

AB = [[] for _ in range(N-1)]

for n in range(N-1):

    AB[n] = list(map(int,input().split()))

PX = [[] for _ in range(Q)]

for q in range(Q):

    PX[q] = list(map(int,input().split()))

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

for ab in AB:

    graph[ab[0]].append(ab[1])

    graph[ab[1]].append(ab[0])

val = [0] * (N+1)

for px in PX:

    val[px[0]] += px[1]

parent = [0] * (N+1)

from collections import deque

Q  = deque([1])

while Q:

    q = Q.popleft()

    for c in graph[q]:

        if c == parent[q]:

            continue

        parent[c] = q

        Q.append(c)

        val[c] += val[q]

print((*val[1:]))

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:]))))

N, Q = list(map(int, input().split()))
AB = [[] for _ in range(N - 1)]
for n in range(N - 1):
    AB[n] = list(map(int, input().split()))
PX = [[] for _ in range(Q)]
for q in range(Q):
    PX[q] = list(map(int, input().split()))
graph = [[] for _ in range(N + 1)]
for ab in AB:
    graph[ab[0]].append(ab[1])
    graph[ab[1]].append(ab[0])
val = [0] * (N + 1)
for px in PX:
    val[px[0]] += px[1]
parent = [0] * (N + 1)
from collections import deque

Q = deque([1])
while Q:
    q = Q.popleft()
    for c in graph[q]:
        if c == parent[q]:
            continue
        parent[c] = q
        Q.append(c)
        val[c] += val[q]
print((*val[1:]))

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:]))))

-N, Q = list(map(int, input().split())) -AB = [[] for _ in range(N - 1)] -for n in range(N - 1): -    AB[n] = list(map(int, input().split())) -PX = [[] for _ in range(Q)] -for q in range(Q): -    PX[q] = list(map(int, input().split())) +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 :]) -for ab in AB: -    graph[ab[0]].append(ab[1]) -    graph[ab[1]].append(ab[0]) +for a, b in zip(AB, AB): +    graph[a].append(b) +    graph[b].append(a) -for px in PX: -    val[px[0]] += px[1] +for p, x in zip(PX, PX): +    val[p] += x +stack = [1] -from collections import deque - -Q = deque([1]) -while Q: -    q = Q.popleft() -    for c in graph[q]: -        if c == parent[q]: +while stack: +    x = stack.pop() +    for y in graph[x]: +        if y == parent[x]: -        parent[c] = q -        Q.append(c) -        val[c] += val[q] -print((*val[1:])) +        parent[y] = x +        stack.append(y) +        val[y] += val[x] +print((" ".join(map(str, val[1:]))))