import sys

input = sys.stdin.readline



N, Q = list(map(int, input().split()))

a = [0]*(N) #1 index

b = [0]*(N) #1 index

p = [0]*(Q+1) #1 index

x = [0]*(Q+1) #1 index

counter = [0]*(N+1) #1 index

for i in range(1, N):

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

for i in range(1, Q+1):

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

    counter[p[i]] += x[i]



from collections import deque

graph = {i: deque() for i in range(1, N+1)}

for i in range(1, N):

    graph[a[i]].append(b[i])

    graph[b[i]].append(a[i])





def dfs(v):

    seen = [0]*(N+1)

    stack = []

    seen[v] = 1

    stack.append(v)

    while stack:

        s = stack[-1]

        if not graph[s]:

            stack.pop()

            continue

        g = graph[s].popleft()

        if seen[g]:

            continue

        seen[g] = 1

        stack.append(g)

        counter[g] += counter[s]



dfs(v=1)

print((*counter[1:]))

from collections import deque, defaultdict

N, Q = list(map(int, input().split()))

G = defaultdict(lambda: deque())

for _ in range(N-1):

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

    G[a].append(b)

    G[b].append(a)

   

cnt = [0]*(N+1)

for _ in range(Q):

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

    cnt[p] += x



def dfs(v, cnt):

    seen = [0] * (N+1)

    seen[v] = 1

    stack = [v]

    while stack:

        v = stack[-1]

        if G[v]:

            w = G[v].popleft()

            if not seen[w]: # if 訪れていなければ

                cnt[w] += cnt[v]

                seen[w] = 1

                stack.append(w)

        else:

            stack.pop()

    return cnt



cnt = dfs(1, cnt)

print((*cnt[1:]))
import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
a = [0] * (N)  # 1 index
b = [0] * (N)  # 1 index
p = [0] * (Q + 1)  # 1 index
x = [0] * (Q + 1)  # 1 index
counter = [0] * (N + 1)  # 1 index
for i in range(1, N):
    a[i], b[i] = list(map(int, input().split()))
for i in range(1, Q + 1):
    p[i], x[i] = list(map(int, input().split()))
    counter[p[i]] += x[i]
from collections import deque

graph = {i: deque() for i in range(1, N + 1)}
for i in range(1, N):
    graph[a[i]].append(b[i])
    graph[b[i]].append(a[i])


def dfs(v):
    seen = [0] * (N + 1)
    stack = []
    seen[v] = 1
    stack.append(v)
    while stack:
        s = stack[-1]
        if not graph[s]:
            stack.pop()
            continue
        g = graph[s].popleft()
        if seen[g]:
            continue
        seen[g] = 1
        stack.append(g)
        counter[g] += counter[s]


dfs(v=1)
print((*counter[1:]))

from collections import deque, defaultdict

N, Q = list(map(int, input().split()))
G = defaultdict(lambda: deque())
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    G[a].append(b)
    G[b].append(a)
cnt = [0] * (N + 1)
for _ in range(Q):
    p, x = list(map(int, input().split()))
    cnt[p] += x


def dfs(v, cnt):
    seen = [0] * (N + 1)
    seen[v] = 1
    stack = [v]
    while stack:
        v = stack[-1]
        if G[v]:
            w = G[v].popleft()
            if not seen[w]:  # if 訪れていなければ
                cnt[w] += cnt[v]
                seen[w] = 1
                stack.append(w)
        else:
            stack.pop()
    return cnt


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

-import sys +from collections import deque, defaultdict -input = sys.stdin.readline -a = [0] * (N)  # 1 index -b = [0] * (N)  # 1 index -p = [0] * (Q + 1)  # 1 index -x = [0] * (Q + 1)  # 1 index -counter = [0] * (N + 1)  # 1 index -for i in range(1, N): -    a[i], b[i] = list(map(int, input().split())) -for i in range(1, Q + 1): -    p[i], x[i] = list(map(int, input().split())) -    counter[p[i]] += x[i] -from collections import deque - -graph = {i: deque() for i in range(1, N + 1)} -for i in range(1, N): -    graph[a[i]].append(b[i]) -    graph[b[i]].append(a[i]) +G = defaultdict(lambda: deque()) +for _ in range(N - 1): +    a, b = list(map(int, input().split())) +    G[a].append(b) +    G[b].append(a) +cnt = [0] * (N + 1) +for _ in range(Q): +    p, x = list(map(int, input().split())) +    cnt[p] += x -def dfs(v): +def dfs(v, cnt): -    stack = [] -    stack.append(v) +    stack = [v] -        s = stack[-1] -        if not graph[s]: +        v = stack[-1] +        if G[v]: +            w = G[v].popleft() +            if not seen[w]:  # if 訪れていなければ +                cnt[w] += cnt[v] +                seen[w] = 1 +                stack.append(w) +        else: -            continue -        g = graph[s].popleft() -        if seen[g]: -            continue -        seen[g] = 1 -        stack.append(g) -        counter[g] += counter[s] +    return cnt -dfs(v=1) -print((*counter[1:])) +cnt = dfs(1, cnt) +print((*cnt[1:]))