from collections import deque





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

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

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



tree = [[] for i in range(n)]

for i in range(n-1):

    tree[info[i][0] - 1].append(info[i][1] - 1)

    tree[info[i][1] - 1].append(info[i][0] - 1)



memo = {}

for i in range(n):

    memo[i] = 0

for i in range(q):

    memo[p[i][0] - 1] += p[i][1]



dp = [0] * n

visited = [False]*n

q = deque([0])

visited[0] = True

dp[0] = memo[0]



while q:

    pos = q.popleft()

    for next_pos in tree[pos]:

        if visited[next_pos]:

            continue

        visited[next_pos] = True

        dp[next_pos] += dp[pos] + memo[next_pos]

        q.append(next_pos)

print((*dp))
from collections import deque

import sys





input = sys.stdin.readline

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

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

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



tree = [[] for i in range(n)]

for i in range(n-1):

    tree[info[i][0] - 1].append(info[i][1] - 1)

    tree[info[i][1] - 1].append(info[i][0] - 1)



memo = {}

for i in range(n):

    memo[i] = 0

for i in range(q):

    memo[p[i][0] - 1] += p[i][1]



dp = [0] * n

visited = [False]*n

q = deque([0])

visited[0] = True

dp[0] = memo[0]



while q:

    pos = q.popleft()

    for next_pos in tree[pos]:

        if visited[next_pos]:

            continue

        visited[next_pos] = True

        dp[next_pos] += dp[pos] + memo[next_pos]

        q.append(next_pos)

print((*dp))

from collections import deque

n, q = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(n - 1)]
p = [list(map(int, input().split())) for i in range(q)]
tree = [[] for i in range(n)]
for i in range(n - 1):
    tree[info[i][0] - 1].append(info[i][1] - 1)
    tree[info[i][1] - 1].append(info[i][0] - 1)
memo = {}
for i in range(n):
    memo[i] = 0
for i in range(q):
    memo[p[i][0] - 1] += p[i][1]
dp = [0] * n
visited = [False] * n
q = deque([0])
visited[0] = True
dp[0] = memo[0]
while q:
    pos = q.popleft()
    for next_pos in tree[pos]:
        if visited[next_pos]:
            continue
        visited[next_pos] = True
        dp[next_pos] += dp[pos] + memo[next_pos]
        q.append(next_pos)
print((*dp))

from collections import deque
import sys

input = sys.stdin.readline
n, q = list(map(int, input().split()))
info = [tuple(map(int, input().split())) for i in range(n - 1)]
p = [tuple(map(int, input().split())) for i in range(q)]
tree = [[] for i in range(n)]
for i in range(n - 1):
    tree[info[i][0] - 1].append(info[i][1] - 1)
    tree[info[i][1] - 1].append(info[i][0] - 1)
memo = {}
for i in range(n):
    memo[i] = 0
for i in range(q):
    memo[p[i][0] - 1] += p[i][1]
dp = [0] * n
visited = [False] * n
q = deque([0])
visited[0] = True
dp[0] = memo[0]
while q:
    pos = q.popleft()
    for next_pos in tree[pos]:
        if visited[next_pos]:
            continue
        visited[next_pos] = True
        dp[next_pos] += dp[pos] + memo[next_pos]
        q.append(next_pos)
print((*dp))

+import sys +input = sys.stdin.readline -info = [list(map(int, input().split())) for i in range(n - 1)] -p = [list(map(int, input().split())) for i in range(q)] +info = [tuple(map(int, input().split())) for i in range(n - 1)] +p = [tuple(map(int, input().split())) for i in range(q)]