from collections import deque

import sys

input = sys.stdin.readline



n, q = (int(i) for i in input().split())

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



for _ in range(n-1):

    a, b = (int(i) for i in input().split())

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

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



ans = [0] * n



for _ in range(q):

    p, x = (int(i) for i in input().split())

    ans[p-1] += x



query = deque([(0, -1)])

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

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)



counter = [0] * n



for _ in range(q):

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

    counter[p-1] += x



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

while query:

    current, parent = query.popleft()

    value = counter[current]

    for node in tree[current]:

        if node == parent:

            continue

        else:

            counter[node] += value

            query.append((node, current))



print((*counter))
from collections import deque
import sys

input = sys.stdin.readline
n, q = (int(i) for i in input().split())
tree = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = (int(i) for i in input().split())
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)
ans = [0] * n
for _ in range(q):
    p, x = (int(i) for i in input().split())
    ans[p - 1] += x
query = deque([(0, -1)])
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
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)
counter = [0] * n
for _ in range(q):
    p, x = list(map(int, input().split()))
    counter[p - 1] += x
query = deque([(0, -1)])  # current, parent
while query:
    current, parent = query.popleft()
    value = counter[current]
    for node in tree[current]:
        if node == parent:
            continue
        else:
            counter[node] += value
            query.append((node, current))
print((*counter))

-n, q = (int(i) for i in input().split()) +n, q = list(map(int, input().split())) -    a, b = (int(i) for i in input().split()) +    a, b = list(map(int, input().split())) -ans = [0] * n +counter = [0] * n -    p, x = (int(i) for i in input().split()) -    ans[p - 1] += x -query = deque([(0, -1)]) +    p, x = list(map(int, input().split())) +    counter[p - 1] += x +query = deque([(0, -1)])  # current, parent -    current_node, parent_node = query.popleft() -    current_value = ans[current_node] -    for node in tree[current_node]: -        if node == parent_node: +    current, parent = query.popleft() +    value = counter[current] +    for node in tree[current]: +        if node == parent: -            ans[node] += current_value -            query.append([node, current_node]) -print((*ans)) +            counter[node] += value +            query.append((node, current)) +print((*counter))