from collections import deque



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

AB = [list(map(int, input().split())) for i in range(N-1)]



graph = [[] for i in range(N+1)]

for i,j in AB:

    graph[i].append(j)

    graph[j].append(i)



c = [0] * (N+1)

for i in range(q):

    p1 , x1 = list(map(int, input().split()))

    c[p1] += x1

    

r = [-1 for i in range(N+1)] 

Q = deque()

Q.append(1)

r[1] = 0



while Q:

    x = Q.pop()

    for to in graph[x]:

        if r[to] == -1:

            c[to] += c[x]

            r[to] = 0 

            Q.append(to)



ans = ""

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

    ans += str(c[i]) + " "

print(ans)
from collections import deque

import sys



input = sys.stdin.readline

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

AB = [list(map(int, input().split())) for i in range(N-1)]



graph = [[] for i in range(N+1)]

for i,j in AB:

    graph[i].append(j)

    graph[j].append(i)



c = [0] * (N+1)

for i in range(q):

    p1 , x1 = list(map(int, input().split()))

    c[p1] += x1

    

r = [-1 for i in range(N+1)] 

Q = deque()

Q.append(1)

r[1] = 0



while Q:

    x = Q.pop()

    for to in graph[x]:

        if r[to] == -1:

            c[to] += c[x]

            r[to] = 0 

            Q.append(to)



ans = ""

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

    ans += str(c[i]) + " "

print(ans)
from collections import deque

N, q = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(N - 1)]
graph = [[] for i in range(N + 1)]
for i, j in AB:
    graph[i].append(j)
    graph[j].append(i)
c = [0] * (N + 1)
for i in range(q):
    p1, x1 = list(map(int, input().split()))
    c[p1] += x1
r = [-1 for i in range(N + 1)]
Q = deque()
Q.append(1)
r[1] = 0
while Q:
    x = Q.pop()
    for to in graph[x]:
        if r[to] == -1:
            c[to] += c[x]
            r[to] = 0
            Q.append(to)
ans = ""
for i in range(1, N + 1):
    ans += str(c[i]) + " "
print(ans)

from collections import deque
import sys

input = sys.stdin.readline
N, q = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(N - 1)]
graph = [[] for i in range(N + 1)]
for i, j in AB:
    graph[i].append(j)
    graph[j].append(i)
c = [0] * (N + 1)
for i in range(q):
    p1, x1 = list(map(int, input().split()))
    c[p1] += x1
r = [-1 for i in range(N + 1)]
Q = deque()
Q.append(1)
r[1] = 0
while Q:
    x = Q.pop()
    for to in graph[x]:
        if r[to] == -1:
            c[to] += c[x]
            r[to] = 0
            Q.append(to)
ans = ""
for i in range(1, N + 1):
    ans += str(c[i]) + " "
print(ans)

+import sys +input = sys.stdin.readline