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

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

PX = [tuple(map(int,input().split())) for i in range(Q)]



es = [[] for i in range(N)]

for a,b in AB:

    a,b = a-1,b-1

    es[a].append(b)

    es[b].append(a)



xs = [0] * N

for p,x in PX:

    xs[p-1] += x



ans = [0] * N

ans[0] = xs[0]

visited = [0] * N

stack = [0]

while stack:

    v = stack.pop()

    visited[v] = 1

    for to in es[v]:

        if visited[to]: continue

        stack.append(to)

        ans[to] = ans[v] + xs[to]



print((*ans))
import sys

input = sys.stdin.readline

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

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

PX = [tuple(map(int,input().split())) for i in range(Q)]



es = [[] for i in range(N)]

for a,b in AB:

    a,b = a-1,b-1

    es[a].append(b)

    es[b].append(a)



xs = [0] * N

for p,x in PX:

    xs[p-1] += x



ans = [0] * N

ans[0] = xs[0]

visited = [0] * N

stack = [0]

while stack:

    v = stack.pop()

    visited[v] = 1

    for to in es[v]:

        if visited[to]: continue

        stack.append(to)

        ans[to] = ans[v] + xs[to]



print((*ans))
N, Q = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for i in range(N - 1)]
PX = [tuple(map(int, input().split())) for i in range(Q)]
es = [[] for i in range(N)]
for a, b in AB:
    a, b = a - 1, b - 1
    es[a].append(b)
    es[b].append(a)
xs = [0] * N
for p, x in PX:
    xs[p - 1] += x
ans = [0] * N
ans[0] = xs[0]
visited = [0] * N
stack = [0]
while stack:
    v = stack.pop()
    visited[v] = 1
    for to in es[v]:
        if visited[to]:
            continue
        stack.append(to)
        ans[to] = ans[v] + xs[to]
print((*ans))

import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for i in range(N - 1)]
PX = [tuple(map(int, input().split())) for i in range(Q)]
es = [[] for i in range(N)]
for a, b in AB:
    a, b = a - 1, b - 1
    es[a].append(b)
    es[b].append(a)
xs = [0] * N
for p, x in PX:
    xs[p - 1] += x
ans = [0] * N
ans[0] = xs[0]
visited = [0] * N
stack = [0]
while stack:
    v = stack.pop()
    visited[v] = 1
    for to in es[v]:
        if visited[to]:
            continue
        stack.append(to)
        ans[to] = ans[v] + xs[to]
print((*ans))

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