from collections import defaultdict

import sys

sys.setrecursionlimit(10**6)



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



graph = defaultdict(set)



for i in range(n - 1):

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

    graph[a].add(b)

    graph[b].add(a)



arr = [0] * (n + 1)



for i in range(q):

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

    arr[p] += x





def solve():

    stack = [1]

    visited = [True] * 2 + [False] * (n - 1)



    while stack:

        curr = stack.pop()

        for leaf in graph[curr]:

            if visited[leaf]:

                continue

            stack.append(leaf)

            visited[leaf] = True

            arr[leaf] += arr[curr]



    return arr





arr = solve()



print((*arr[1:]))
from collections import defaultdict

import sys

sys.setrecursionlimit(10**7)





def dfs(prev, u):

    if visited[u]:

        return

    else:

        cnt[u] += cnt[prev]

        visited[u] = True

        for nu in graph[u]:

            if visited[nu]:

                continue

            else:

                dfs(u, nu)





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

graph = defaultdict(list)



for _ in range(n - 1):

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

    graph[a].append(b)

    graph[b].append(a)



cnt = [0] * (n + 1)



for _ in range(q):

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

    cnt[p] += x



visited = [True] + [False] * n



dfs(0, 1)



print((*cnt[1:]))
from collections import defaultdict
import sys

sys.setrecursionlimit(10**6)
n, q = list(map(int, input().split()))
graph = defaultdict(set)
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    graph[a].add(b)
    graph[b].add(a)
arr = [0] * (n + 1)
for i in range(q):
    p, x = list(map(int, input().split()))
    arr[p] += x


def solve():
    stack = [1]
    visited = [True] * 2 + [False] * (n - 1)
    while stack:
        curr = stack.pop()
        for leaf in graph[curr]:
            if visited[leaf]:
                continue
            stack.append(leaf)
            visited[leaf] = True
            arr[leaf] += arr[curr]
    return arr


arr = solve()
print((*arr[1:]))

from collections import defaultdict
import sys

sys.setrecursionlimit(10**7)


def dfs(prev, u):
    if visited[u]:
        return
    else:
        cnt[u] += cnt[prev]
        visited[u] = True
        for nu in graph[u]:
            if visited[nu]:
                continue
            else:
                dfs(u, nu)


n, q = list(map(int, input().split()))
graph = defaultdict(list)
for _ in range(n - 1):
    a, b = list(map(int, input().split()))
    graph[a].append(b)
    graph[b].append(a)
cnt = [0] * (n + 1)
for _ in range(q):
    p, x = list(map(int, input().split()))
    cnt[p] += x
visited = [True] + [False] * n
dfs(0, 1)
print((*cnt[1:]))

-sys.setrecursionlimit(10**6) -n, q = list(map(int, input().split())) -graph = defaultdict(set) -for i in range(n - 1): -    a, b = list(map(int, input().split())) -    graph[a].add(b) -    graph[b].add(a) -arr = [0] * (n + 1) -for i in range(q): -    p, x = list(map(int, input().split())) -    arr[p] += x +sys.setrecursionlimit(10**7) -def solve(): -    stack = [1] -    visited = [True] * 2 + [False] * (n - 1) -    while stack: -        curr = stack.pop() -        for leaf in graph[curr]: -            if visited[leaf]: +def dfs(prev, u): +    if visited[u]: +        return +    else: +        cnt[u] += cnt[prev] +        visited[u] = True +        for nu in graph[u]: +            if visited[nu]: -            stack.append(leaf) -            visited[leaf] = True -            arr[leaf] += arr[curr] -    return arr +            else: +                dfs(u, nu) -arr = solve() -print((*arr[1:])) +n, q = list(map(int, input().split())) +graph = defaultdict(list) +for _ in range(n - 1): +    a, b = list(map(int, input().split())) +    graph[a].append(b) +    graph[b].append(a) +cnt = [0] * (n + 1) +for _ in range(q): +    p, x = list(map(int, input().split())) +    cnt[p] += x +visited = [True] + [False] * n +dfs(0, 1) +print((*cnt[1:]))