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

AB = [[] for _ in range(N-1)]

for n in range(N-1):

    AB[n] = list(map(int,input().split()))

PX = [[] for _ in range(Q)]

for q in range(Q):

    PX[q] = list(map(int,input().split()))

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

for ab in AB:

    graph[ab[0]].append(ab[1])

    graph[ab[1]].append(ab[0])

val = [0] * (N+1)

for px in PX:

    val[px[0]] += px[1]

parent = [0] * (N+1)

Q  = [1]

while Q:

    q = Q.pop()

    for c in graph[q]:

        if c == parent[q]:

            continue

        parent[c] = q

        Q.append(c)

        val[c] += val[q]

print((*val[1:]))

import sys

input = sys.stdin.readline

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

AB = [[] for _ in range(N-1)]

for n in range(N-1):

    AB[n] = list(map(int,input().split()))

PX = [[] for _ in range(Q)]

for q in range(Q):

    PX[q] = list(map(int,input().split()))

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

for ab in AB:

    graph[ab[0]].append(ab[1])

    graph[ab[1]].append(ab[0])

val = [0] * (N+1)

for px in PX:

    val[px[0]] += px[1]

parent = [0] * (N+1)

Q  = [1]

while Q:

    q = Q.pop()

    for c in graph[q]:

        if c == parent[q]:

            continue

        parent[c] = q

        Q.append(c)

        val[c] += val[q]

print((*val[1:]))

N, Q = list(map(int, input().split()))
AB = [[] for _ in range(N - 1)]
for n in range(N - 1):
    AB[n] = list(map(int, input().split()))
PX = [[] for _ in range(Q)]
for q in range(Q):
    PX[q] = list(map(int, input().split()))
graph = [[] for _ in range(N + 1)]
for ab in AB:
    graph[ab[0]].append(ab[1])
    graph[ab[1]].append(ab[0])
val = [0] * (N + 1)
for px in PX:
    val[px[0]] += px[1]
parent = [0] * (N + 1)
Q = [1]
while Q:
    q = Q.pop()
    for c in graph[q]:
        if c == parent[q]:
            continue
        parent[c] = q
        Q.append(c)
        val[c] += val[q]
print((*val[1:]))

import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
AB = [[] for _ in range(N - 1)]
for n in range(N - 1):
    AB[n] = list(map(int, input().split()))
PX = [[] for _ in range(Q)]
for q in range(Q):
    PX[q] = list(map(int, input().split()))
graph = [[] for _ in range(N + 1)]
for ab in AB:
    graph[ab[0]].append(ab[1])
    graph[ab[1]].append(ab[0])
val = [0] * (N + 1)
for px in PX:
    val[px[0]] += px[1]
parent = [0] * (N + 1)
Q = [1]
while Q:
    q = Q.pop()
    for c in graph[q]:
        if c == parent[q]:
            continue
        parent[c] = q
        Q.append(c)
        val[c] += val[q]
print((*val[1:]))

+import sys + +input = sys.stdin.readline