import sys

from collections import defaultdict

sys.setrecursionlimit(10**6)

readline = sys.stdin.readline



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

G = defaultdict(list)

for _ in range(n-1):

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

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

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

count = [0] * n

for _ in range(q):

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

    count[p-1] += x





def dfs(root, x):

    ans[root] = count[root] + x

    for i in G[root]:

        if ans[i] == -1:

            dfs(i, ans[root])





ans = [-1] * n

dfs(0, 0)

print((*ans))

import sys

from collections import defaultdict, deque

sys.setrecursionlimit(10**6)

readline = sys.stdin.readline



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

G = defaultdict(list)

for _ in range(n-1):

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

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

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

count = [0] * n

for _ in range(q):

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

    count[p-1] += x





def dfs(root, x):

    ans[root] = count[root] + x

    for i in G[root]:

        if ans[i] == -1:

            dfs(i, ans[root])





ans = [-1] * n

ans[0] = count[0]

q = deque([0])

while q:

    root = q.pop()

    for i in G[root]:

        if ans[i] == -1:

            q.append(i)

            ans[i] = ans[root] + count[i]



# dfs(0, 0)

print((*ans))

import sys
from collections import defaultdict

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


def dfs(root, x):
    ans[root] = count[root] + x
    for i in G[root]:
        if ans[i] == -1:
            dfs(i, ans[root])


ans = [-1] * n
dfs(0, 0)
print((*ans))

import sys
from collections import defaultdict, deque

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


def dfs(root, x):
    ans[root] = count[root] + x
    for i in G[root]:
        if ans[i] == -1:
            dfs(i, ans[root])


ans = [-1] * n
ans[0] = count[0]
q = deque([0])
while q:
    root = q.pop()
    for i in G[root]:
        if ans[i] == -1:
            q.append(i)
            ans[i] = ans[root] + count[i]
# dfs(0, 0)
print((*ans))

-from collections import defaultdict +from collections import defaultdict, deque -dfs(0, 0) +ans[0] = count[0] +q = deque([0]) +while q: +    root = q.pop() +    for i in G[root]: +        if ans[i] == -1: +            q.append(i) +            ans[i] = ans[root] + count[i] +# dfs(0, 0)