from pprint import pprint

from collections import deque, defaultdict



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

# edges = defaultdict(set)

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

for _ in range(n-1):

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

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

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

    # edges[a_i-1].add(b_i-1)

    # edges[b_i-1].add(a_i-1)



# p = defaultdict(int)

# counter = defaultdict(int)

counter = [0] * n

p = [0] * n

for _ in range(q):

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

    # p[p_i-1] += x_i

    counter[p_i-1] += x_i





parents = deque()

# parents.append(0)

# parents = []

parents.append(0)

visited = set()

while parents:

    parent = parents.popleft()

    # parent = parents.pop()

    if parent in visited:

        continue

    visited.add(parent)

    # counter[parent] += p[parent]

    # print("parent")

    # print(parent, counter[parent])

    for child in edges[parent]:

        if child in visited:

            continue

        # if counter[child] != 0:

        #    continue

        counter[child] += counter[parent]

        # print("child")

        # print(child, counter[child])

        parents.append(child)

        # parents.add(child)



#print(" ".join(list(map(str, counter.values()))))

#print(" ".join(list(map(str, counter))))

print((*counter))
from pprint import pprint

from collections import deque



import sys



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

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

for _ in range(n-1):

    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 = list(map(int, sys.stdin.readline().strip().split(" ")))

    counter[p_i-1] += x_i





parents = deque()

parents.append(0)

visited = set()

while parents:

    parent = parents.popleft()

    if parent in visited:

        continue

    visited.add(parent)

    for child in edges[parent]:

        if child in visited:

            continue

        counter[child] += counter[parent]

        parents.append(child)



print((" ".join(list(map(str, counter)))))
from pprint import pprint
from collections import deque, defaultdict

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

from pprint import pprint
from collections import deque
import sys

n, q = list(map(int, sys.stdin.readline().strip().split(" ")))
edges = [[] for _ in range(n)]
for _ in range(n - 1):
    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 = list(map(int, sys.stdin.readline().strip().split(" ")))
    counter[p_i - 1] += x_i
parents = deque()
parents.append(0)
visited = set()
while parents:
    parent = parents.popleft()
    if parent in visited:
        continue
    visited.add(parent)
    for child in edges[parent]:
        if child in visited:
            continue
        counter[child] += counter[parent]
        parents.append(child)
print((" ".join(list(map(str, counter)))))

-from collections import deque, defaultdict +from collections import deque +import sys -n, q = list(map(int, input().strip().split(" "))) -# edges = defaultdict(set) +n, q = list(map(int, sys.stdin.readline().strip().split(" "))) -    a_i, b_i = list(map(int, input().strip().split(" "))) +    a_i, b_i = list(map(int, sys.stdin.readline().strip().split(" "))) -    # edges[a_i-1].add(b_i-1) -    # edges[b_i-1].add(a_i-1) -# p = defaultdict(int) -# counter = defaultdict(int) -    p_i, x_i = list(map(int, input().strip().split(" "))) -    # p[p_i-1] += x_i +    p_i, x_i = list(map(int, sys.stdin.readline().strip().split(" "))) -# parents.append(0) -# parents = [] -    # parent = parents.pop() -    # counter[parent] += p[parent] -    # print("parent") -    # print(parent, counter[parent]) -        # if counter[child] != 0: -        #    continue -        # print("child") -        # print(child, counter[child]) -        # parents.add(child) -# print(" ".join(list(map(str, counter.values())))) -# print(" ".join(list(map(str, counter)))) -print((*counter)) +print((" ".join(list(map(str, counter)))))