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

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

for _ in range(N - 1):

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

    graph[a].append(b)

    graph[b].append(a)



C = [0] * (N + 1)

for _ in range(Q):

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

    C[p] += x



se = set([1])

stack = [1]

while stack:

    # print(C)

    x = stack.pop()

    for y in graph[x]:

        if y in se:

            continue

        stack.append(y)

        se.add(y)

        # 親x, 子y

        C[y] += C[x]



print((' '.join(str(i) for i in C[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)



C = [0] * (N+1)

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

    C[p] += x



se = set([1])

stack = [1]

while stack:

    # print(C)

    x = stack.pop()

    for y in graph[x]:

        if y in se:

            continue

        stack.append(y)

        se.add(y)

        # 親x, 子y

        C[y] += C[x]



print((' '.join(str(i) for i in C[1:])))

N, Q = list(map(int, input().split()))
graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    graph[a].append(b)
    graph[b].append(a)
C = [0] * (N + 1)
for _ in range(Q):
    p, x = list(map(int, input().split()))
    C[p] += x
se = set([1])
stack = [1]
while stack:
    # print(C)
    x = stack.pop()
    for y in graph[x]:
        if y in se:
            continue
        stack.append(y)
        se.add(y)
        # 親x, 子y
        C[y] += C[x]
print((" ".join(str(i) for i in C[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)
C = [0] * (N + 1)
for p, x in zip(PX, PX):
    C[p] += x
se = set([1])
stack = [1]
while stack:
    # print(C)
    x = stack.pop()
    for y in graph[x]:
        if y in se:
            continue
        stack.append(y)
        se.add(y)
        # 親x, 子y
        C[y] += C[x]
print((" ".join(str(i) for i in C[1:])))

-N, 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 _ in range(N - 1): -    a, b = list(map(int, input().split())) +for a, b in zip(AB, AB): -for _ in range(Q): -    p, x = list(map(int, input().split())) +for p, x in zip(PX, PX):