import sys

sys.setrecursionlimit(10**6)

input = sys.stdin.readline



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



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



for i in range(n-1):

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

    tree[a-1].append(b-1)

    tree[b-1].append(a-1)



add = [0] * n



for i in range(q):

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

    add[p-1] += x



ans = [0] * n



def dfs(v, p, value):

    value += add[v]

    ans[v] = value

    for c in tree[v]:

        if c == p:

            continue

        dfs(c, v, value)



dfs(0, -1, 0)



print((*ans))
from collections import deque

import sys

input = sys.stdin.readline



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

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



for _ in range(n-1):

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

    tree[a-1].append(b-1)

    tree[b-1].append(a-1)



ans = [0] * n



for _ in range(q):

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

    ans[p-1] += x



query = deque([(0, -1)]) # current, parent

while query:

    current_node, parent_node = query.popleft()

    current_value = ans[current_node]

    for node in tree[current_node]:

        if node == parent_node:

            continue

        else:

            ans[node] += current_value

            query.append([node, current_node])



print((*ans))
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n, q = list(map(int, input().split()))
tree = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)
add = [0] * n
for i in range(q):
    p, x = list(map(int, input().split()))
    add[p - 1] += x
ans = [0] * n


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


dfs(0, -1, 0)
print((*ans))

from collections import deque
import sys

input = sys.stdin.readline
n, q = list(map(int, input().split()))
tree = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = list(map(int, input().split()))
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)
ans = [0] * n
for _ in range(q):
    p, x = list(map(int, input().split()))
    ans[p - 1] += x
query = deque([(0, -1)])  # current, parent
while query:
    current_node, parent_node = query.popleft()
    current_value = ans[current_node]
    for node in tree[current_node]:
        if node == parent_node:
            continue
        else:
            ans[node] += current_value
            query.append([node, current_node])
print((*ans))

+from collections import deque -sys.setrecursionlimit(10**6) -for i in range(n - 1): +for _ in range(n - 1): -add = [0] * n -for i in range(q): +ans = [0] * n +for _ in range(q): -    add[p - 1] += x -ans = [0] * n - - -def dfs(v, p, value): -    value += add[v] -    ans[v] = value -    for c in tree[v]: -        if c == p: +    ans[p - 1] += x +query = deque([(0, -1)])  # current, parent +while query: +    current_node, parent_node = query.popleft() +    current_value = ans[current_node] +    for node in tree[current_node]: +        if node == parent_node: -        dfs(c, v, value) - - -dfs(0, -1, 0) +        else: +            ans[node] += current_value +            query.append([node, current_node])