from collections import deque

#グラフの連結成分を調べる

def Graph(ab):

    G=[[] for i in range(n)]

    for a,b in ab:

        G[a-1].append(b)

        G[b-1].append(a)

    return G



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

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

px = [list(map(int,input().split())) for i in range(q)]



G = Graph(ab)

ki = [0] * n



for i in range(q):

    root, score = px[i]

    ki[root - 1] += score



q = deque()

q.append((1, -1))



while q:

    v, p = q.popleft()

    for next in G[v - 1]:

        if next == p:continue

        ki[next - 1] += ki[v - 1]

        q.append((next, v))

print((*ki))
import sys

input=sys.stdin.readline

from collections import deque

#グラフの連結成分を調べる

def Graph(ab):

    G=[[] for i in range(n)]

    for a,b in ab:

        G[a-1].append(b)

        G[b-1].append(a)

    return G



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

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

px = [list(map(int,input().split())) for i in range(q)]



G = Graph(ab)

ki = [0] * n



for i in range(q):

    root, score = px[i]

    ki[root - 1] += score



q = deque()

q.append((1, -1))



while q:

    v, p = q.popleft()

    for next in G[v - 1]:

        if next == p:continue

        ki[next - 1] += ki[v - 1]

        q.append((next, v))

print((*ki))
from collections import deque

# グラフの連結成分を調べる
def Graph(ab):
    G = [[] for i in range(n)]
    for a, b in ab:
        G[a - 1].append(b)
        G[b - 1].append(a)
    return G


n, q = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n - 1)]
px = [list(map(int, input().split())) for i in range(q)]
G = Graph(ab)
ki = [0] * n
for i in range(q):
    root, score = px[i]
    ki[root - 1] += score
q = deque()
q.append((1, -1))
while q:
    v, p = q.popleft()
    for next in G[v - 1]:
        if next == p:
            continue
        ki[next - 1] += ki[v - 1]
        q.append((next, v))
print((*ki))

import sys

input = sys.stdin.readline
from collections import deque

# グラフの連結成分を調べる
def Graph(ab):
    G = [[] for i in range(n)]
    for a, b in ab:
        G[a - 1].append(b)
        G[b - 1].append(a)
    return G


n, q = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n - 1)]
px = [list(map(int, input().split())) for i in range(q)]
G = Graph(ab)
ki = [0] * n
for i in range(q):
    root, score = px[i]
    ki[root - 1] += score
q = deque()
q.append((1, -1))
while q:
    v, p = q.popleft()
    for next in G[v - 1]:
        if next == p:
            continue
        ki[next - 1] += ki[v - 1]
        q.append((next, v))
print((*ki))

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