import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)



n, q = list(map(int, input().split()))

AB = [[int(x) for x in input().split()] for _ in range(n - 1)]

PX = [[int(x) for x in input().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



def dfs(v, parent, add):

	value[v] += add

	for x in graph[v]:

		if x == parent:

			continue

		dfs(x, v, value[v])



dfs(1, 0, 0)

print((*value[1:]))

n, q = list(map(int, input().split()))



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

for i in range(n - 1):

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

    graph[a].append(b)

    graph[b].append(a)



counter = [0] * (n + 1)



for i in range(q):

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

    counter[p] += x



parents = [0] * (n + 1)



q = [1]

while q:

    y = q.pop()

    for x in graph[y]:

        if x == parents[y]:

            continue

        counter[x] += counter[y]

        q.append(x)

        parents[x] = y



print((*counter[1:]))

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, q = list(map(int, input().split()))
AB = [[int(x) for x in input().split()] for _ in range(n - 1)]
PX = [[int(x) for x in input().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


def dfs(v, parent, add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x, v, value[v])


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

n, q = list(map(int, input().split()))
graph = [[] for _ in range(n + 1)]
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    graph[a].append(b)
    graph[b].append(a)
counter = [0] * (n + 1)
for i in range(q):
    p, x = list(map(int, input().split()))
    counter[p] += x
parents = [0] * (n + 1)
q = [1]
while q:
    y = q.pop()
    for x in graph[y]:
        if x == parents[y]:
            continue
        counter[x] += counter[y]
        q.append(x)
        parents[x] = y
print((*counter[1:]))

-import sys - -input = sys.stdin.readline -sys.setrecursionlimit(10**7) -AB = [[int(x) for x in input().split()] for _ in range(n - 1)] -PX = [[int(x) for x in input().split()] for _ in range(q)] -for a, b in AB: +for i in range(n - 1): +    a, b = list(map(int, input().split())) -value = [0] * (n + 1) -for p, x in PX: -    value[p] += x - - -def dfs(v, parent, add): -    value[v] += add -    for x in graph[v]: -        if x == parent: +counter = [0] * (n + 1) +for i in range(q): +    p, x = list(map(int, input().split())) +    counter[p] += x +parents = [0] * (n + 1) +q = [1] +while q: +    y = q.pop() +    for x in graph[y]: +        if x == parents[y]: -        dfs(x, v, value[v]) - - -dfs(1, 0, 0) -print((*value[1:])) +        counter[x] += counter[y] +        q.append(x) +        parents[x] = y +print((*counter[1:]))