from pprint import pprint

from collections import deque, defaultdict

 

import sys

 

# n, q = map(int, input().strip().split(" "))

n, q = list(map(int, sys.stdin.readline().strip().split(" ")))

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

for _ in range(n-1):

    # a_i, b_i = map(int, input().strip().split(" "))

    a_i, b_i = list(map(int, sys.stdin.readline().strip().split(" ")))

    edges[a_i-1].append(b_i-1)

    edges[b_i-1].append(a_i-1)

 

counter = [0] * n

p = [0] * n

for _ in range(q):

    # p_i, x_i = map(int, input().strip().split(" "))

    p_i, x_i = list(map(int, sys.stdin.readline().strip().split(" ")))

    p[p_i-1] += x_i

    # counter[p_i-1] += x_i

 

 

parents = deque()

parents.append(0)

visited = set()

while parents:

    parent = parents.popleft()

    if parent in visited:

        continue

    counter[parent] += p[parent]

    visited.add(parent)

    for child in edges[parent]:

        if child in visited:

            continue

        counter[child] += counter[parent]

        # print("child")

        # print(child, counter[child])

        parents.append(child)

 

print((" ".join(list(map(str, counter)))))
import sys

from collections import deque



N, Q = list(map(int, sys.stdin.readline().split(" ")))



edges = [[] for _ in range(N)]

for _ in range(N-1):

    a, b = list(map(int, sys.stdin.readline().split(" ")))

    # print(a, b)

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

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

# print(edges)

# sys.exit()



points = [0] * N

for _ in range(Q):

    p, x = list(map(int, sys.stdin.readline().split(" ")))

    points[p-1] += x





visited = set()

counted = [0] * N

q = deque([(0, points[0])])

while q:

    node, point = q.popleft()

    # print(node, point)

    if node in visited:

        continue

    counted[node] = str(point)

    visited.add(node)

    for edge in edges[node]:

        q.appendleft((edge, point + points[edge]))



print((" ".join(counted)))
from pprint import pprint
from collections import deque, defaultdict
import sys

# n, q = map(int, input().strip().split(" "))
n, q = list(map(int, sys.stdin.readline().strip().split(" ")))
edges = [[] for _ in range(n)]
for _ in range(n - 1):
    # a_i, b_i = map(int, input().strip().split(" "))
    a_i, b_i = list(map(int, sys.stdin.readline().strip().split(" ")))
    edges[a_i - 1].append(b_i - 1)
    edges[b_i - 1].append(a_i - 1)
counter = [0] * n
p = [0] * n
for _ in range(q):
    # p_i, x_i = map(int, input().strip().split(" "))
    p_i, x_i = list(map(int, sys.stdin.readline().strip().split(" ")))
    p[p_i - 1] += x_i
    # counter[p_i-1] += x_i
parents = deque()
parents.append(0)
visited = set()
while parents:
    parent = parents.popleft()
    if parent in visited:
        continue
    counter[parent] += p[parent]
    visited.add(parent)
    for child in edges[parent]:
        if child in visited:
            continue
        counter[child] += counter[parent]
        # print("child")
        # print(child, counter[child])
        parents.append(child)
print((" ".join(list(map(str, counter)))))

import sys
from collections import deque

N, Q = list(map(int, sys.stdin.readline().split(" ")))
edges = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, sys.stdin.readline().split(" ")))
    # print(a, b)
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)
# print(edges)
# sys.exit()
points = [0] * N
for _ in range(Q):
    p, x = list(map(int, sys.stdin.readline().split(" ")))
    points[p - 1] += x
visited = set()
counted = [0] * N
q = deque([(0, points[0])])
while q:
    node, point = q.popleft()
    # print(node, point)
    if node in visited:
        continue
    counted[node] = str(point)
    visited.add(node)
    for edge in edges[node]:
        q.appendleft((edge, point + points[edge]))
print((" ".join(counted)))

-from pprint import pprint -from collections import deque, defaultdict +from collections import deque -# n, q = map(int, input().strip().split(" ")) -n, q = list(map(int, sys.stdin.readline().strip().split(" "))) -edges = [[] for _ in range(n)] -for _ in range(n - 1): -    # a_i, b_i = map(int, input().strip().split(" ")) -    a_i, b_i = list(map(int, sys.stdin.readline().strip().split(" "))) -    edges[a_i - 1].append(b_i - 1) -    edges[b_i - 1].append(a_i - 1) -counter = [0] * n -p = [0] * n -for _ in range(q): -    # p_i, x_i = map(int, input().strip().split(" ")) -    p_i, x_i = list(map(int, sys.stdin.readline().strip().split(" "))) -    p[p_i - 1] += x_i -    # counter[p_i-1] += x_i -parents = deque() -parents.append(0) +N, Q = list(map(int, sys.stdin.readline().split(" "))) +edges = [[] for _ in range(N)] +for _ in range(N - 1): +    a, b = list(map(int, sys.stdin.readline().split(" "))) +    # print(a, b) +    edges[a - 1].append(b - 1) +    edges[b - 1].append(a - 1) +# print(edges) +# sys.exit() +points = [0] * N +for _ in range(Q): +    p, x = list(map(int, sys.stdin.readline().split(" "))) +    points[p - 1] += x -while parents: -    parent = parents.popleft() -    if parent in visited: +counted = [0] * N +q = deque([(0, points[0])]) +while q: +    node, point = q.popleft() +    # print(node, point) +    if node in visited: -    counter[parent] += p[parent] -    visited.add(parent) -    for child in edges[parent]: -        if child in visited: -            continue -        counter[child] += counter[parent] -        # print("child") -        # print(child, counter[child]) -        parents.append(child) -print((" ".join(list(map(str, counter))))) +    counted[node] = str(point) +    visited.add(node) +    for edge in edges[node]: +        q.appendleft((edge, point + points[edge])) +print((" ".join(counted)))