import sys

sys.setrecursionlimit(10**8)

input = lambda: sys.stdin.readline()[:-1]

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

ab=[tuple(map(int,input().split())) for i in range(n-1)]

px=[tuple(map(int,input().split())) for i in range(q)]

# ab.sort(key=lambda tup:(tup[0],tup[1]))

visited=[0]*(n+1)

cnt=[0]*(n+1)

data=[[] for i in range(n+1)]



for i in ab:

	data[i[0]].append(i[1])

	data[i[1]].append(i[0])

for j in px:

	cnt[j[0]]+=j[1]



visited[1]=1

stack=[1]



while stack:

	v=stack.pop()

	for to in data[v]:

		if visited[to]:

			continue

		visited[to]=1

		cnt[to]+=cnt[v]

		stack.append(to)



	

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

sys.setrecursionlimit(10**8)

input = lambda: sys.stdin.readline()[:-1]

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

ab=[tuple(map(int,input().split())) for i in range(n-1)]

px=[tuple(map(int,input().split())) for i in range(q)]

# ab.sort(key=lambda tup:(tup[0],tup[1]))



cnt=[0]*(n+1)

data=[[] for i in range(n+1)]



for i in ab:

	data[i[0]].append(i[1])

	data[i[1]].append(i[0])

for j in px:

	cnt[j[0]]+=j[1]





stack=[(1,0)]



while stack:

	v,parent=stack.pop()

	for to in data[v]:

		if to == parent:

			continue

		cnt[to]+=cnt[v]

		stack.append((to,v))



	

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

sys.setrecursionlimit(10**8)
input = lambda: sys.stdin.readline()[:-1]
n, q = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for i in range(n - 1)]
px = [tuple(map(int, input().split())) for i in range(q)]
# ab.sort(key=lambda tup:(tup[0],tup[1]))
visited = [0] * (n + 1)
cnt = [0] * (n + 1)
data = [[] for i in range(n + 1)]
for i in ab:
    data[i[0]].append(i[1])
    data[i[1]].append(i[0])
for j in px:
    cnt[j[0]] += j[1]
visited[1] = 1
stack = [1]
while stack:
    v = stack.pop()
    for to in data[v]:
        if visited[to]:
            continue
        visited[to] = 1
        cnt[to] += cnt[v]
        stack.append(to)
print((*cnt[1:]))

import sys

sys.setrecursionlimit(10**8)
input = lambda: sys.stdin.readline()[:-1]
n, q = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for i in range(n - 1)]
px = [tuple(map(int, input().split())) for i in range(q)]
# ab.sort(key=lambda tup:(tup[0],tup[1]))
cnt = [0] * (n + 1)
data = [[] for i in range(n + 1)]
for i in ab:
    data[i[0]].append(i[1])
    data[i[1]].append(i[0])
for j in px:
    cnt[j[0]] += j[1]
stack = [(1, 0)]
while stack:
    v, parent = stack.pop()
    for to in data[v]:
        if to == parent:
            continue
        cnt[to] += cnt[v]
        stack.append((to, v))
print((*cnt[1:]))

-visited = [0] * (n + 1) -visited[1] = 1 -stack = [1] +stack = [(1, 0)] -    v = stack.pop() +    v, parent = stack.pop() -        if visited[to]: +        if to == parent: -        visited[to] = 1 -        stack.append(to) +        stack.append((to, v))