import sys

sys.setrecursionlimit(2 * 10 ** 5 + 10)



N, Q, *ABPX = list(map(int, open(0).read().split()))

AB, PX = ABPX[:2 * (N - 1)], ABPX[2 * (N - 1):]



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

for a, b in zip(*[iter(AB)] * 2):

    E[a].append(b)

    E[b].append(a)



ans = [0] * (N + 1)

for p, x in zip(*[iter(PX)] * 2):

    ans[p] += x



def dfs(v, p):

    for c in E[v]:

        if c == p:

            continue

        ans[c] += ans[v]

        dfs(c, v)



dfs(1, 0)



print((*ans[1:]))
N, Q, *ABPX = list(map(int, open(0).read().split()))

AB, PX = ABPX[:2 * (N - 1)], ABPX[2 * (N - 1):]



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

for a, b in zip(*[iter(AB)] * 2):

    E[a].append(b)

    E[b].append(a)



ans = [0] * (N + 1)

for p, x in zip(*[iter(PX)] * 2):

    ans[p] += x





stack = [(1, 0)]

while stack:

    v, p = stack.pop()

    for c in E[v]:

        if c == p:

            continue

        ans[c] += ans[v]

        stack.append((c, v))



print((*ans[1:]))
import sys

sys.setrecursionlimit(2 * 10**5 + 10)
N, Q, *ABPX = list(map(int, open(0).read().split()))
AB, PX = ABPX[: 2 * (N - 1)], ABPX[2 * (N - 1) :]
E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    E[a].append(b)
    E[b].append(a)
ans = [0] * (N + 1)
for p, x in zip(*[iter(PX)] * 2):
    ans[p] += x


def dfs(v, p):
    for c in E[v]:
        if c == p:
            continue
        ans[c] += ans[v]
        dfs(c, v)


dfs(1, 0)
print((*ans[1:]))

N, Q, *ABPX = list(map(int, open(0).read().split()))
AB, PX = ABPX[: 2 * (N - 1)], ABPX[2 * (N - 1) :]
E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    E[a].append(b)
    E[b].append(a)
ans = [0] * (N + 1)
for p, x in zip(*[iter(PX)] * 2):
    ans[p] += x
stack = [(1, 0)]
while stack:
    v, p = stack.pop()
    for c in E[v]:
        if c == p:
            continue
        ans[c] += ans[v]
        stack.append((c, v))
print((*ans[1:]))

-import sys - -sys.setrecursionlimit(2 * 10**5 + 10) - - -def dfs(v, p): +stack = [(1, 0)] +while stack: +    v, p = stack.pop() -        dfs(c, v) - - -dfs(1, 0) +        stack.append((c, v))