import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(10 ** 7)



from collections import defaultdict, deque



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

graph = defaultdict(list)

for i in range(n - 1):

    u, v = list(map(int, readline().split()))

    graph[u - 1].append(v - 1)

    graph[v - 1].append(u - 1)

v = [0] * n

for i in range(q):

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

    v[p - 1] += x





def dfs(s):

    check = [False] * n

    stack = deque([s])

    while stack:

        now = stack.pop()

        check[now] = True

        for next in graph[now]:

            if check[next]:

                continue

            v[next] += v[now]

            stack.appendleft(next)





dfs(0)

print((*v))

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(10 ** 7)



from collections import deque



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

graph = [[] for _ in range(n + 1)]

for i in range(n - 1):

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

    graph[a].append(b)

    graph[b].append(a)

cnt = [0] * (n + 1)

for i in range(q):

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

    cnt[p] += x





def dfs(s):

    check = [False] * (n + 1)

    stack = deque([s])

    while stack:

        now = stack.pop()

        check[now] = True

        for nxt in graph[now]:

            if check[nxt]:

                continue

            stack.appendleft(nxt)

            cnt[nxt] += cnt[now]





dfs(1)

print((*cnt[1:]))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
from collections import defaultdict, deque

n, q = list(map(int, readline().split()))
graph = defaultdict(list)
for i in range(n - 1):
    u, v = list(map(int, readline().split()))
    graph[u - 1].append(v - 1)
    graph[v - 1].append(u - 1)
v = [0] * n
for i in range(q):
    p, x = list(map(int, readline().split()))
    v[p - 1] += x


def dfs(s):
    check = [False] * n
    stack = deque([s])
    while stack:
        now = stack.pop()
        check[now] = True
        for next in graph[now]:
            if check[next]:
                continue
            v[next] += v[now]
            stack.appendleft(next)


dfs(0)
print((*v))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
from collections import deque

n, q = list(map(int, readline().split()))
graph = [[] for _ in range(n + 1)]
for i in range(n - 1):
    a, b = list(map(int, readline().split()))
    graph[a].append(b)
    graph[b].append(a)
cnt = [0] * (n + 1)
for i in range(q):
    p, x = list(map(int, readline().split()))
    cnt[p] += x


def dfs(s):
    check = [False] * (n + 1)
    stack = deque([s])
    while stack:
        now = stack.pop()
        check[now] = True
        for nxt in graph[now]:
            if check[nxt]:
                continue
            stack.appendleft(nxt)
            cnt[nxt] += cnt[now]


dfs(1)
print((*cnt[1:]))

-from collections import defaultdict, deque +from collections import deque -graph = defaultdict(list) +graph = [[] for _ in range(n + 1)] -    u, v = list(map(int, readline().split())) -    graph[u - 1].append(v - 1) -    graph[v - 1].append(u - 1) -v = [0] * n +    a, b = list(map(int, readline().split())) +    graph[a].append(b) +    graph[b].append(a) +cnt = [0] * (n + 1) -    v[p - 1] += x +    cnt[p] += x -    check = [False] * n +    check = [False] * (n + 1) -        for next in graph[now]: -            if check[next]: +        for nxt in graph[now]: +            if check[nxt]: -            v[next] += v[now] -            stack.appendleft(next) +            stack.appendleft(nxt) +            cnt[nxt] += cnt[now] -dfs(0) -print((*v)) +dfs(1) +print((*cnt[1:]))