import sys

input = sys.stdin.readline

sys.setrecursionlimit(1000000)

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) ]

dic = {}

dic2=[0]*(N+1)

dic3=[0]*N



for i in range(N):

    dic[i+1] = []

for i in range(N-1):

    tmp1 = ab[i][0]

    tmp2 = ab[i][1]

    dic[tmp1].append(tmp2)

    dic[tmp2].append(tmp1)

ab=0

for i in range(Q):

    dic2[px[i][0]] += px[i][1]

px=0

def rec(now_node,prevval):

    nowval = prevval + dic2[now_node]

    dic3[now_node-1] = nowval

    tg_list = dic[now_node][:]

    for elem in tg_list:

        dic[elem].remove(now_node)

        rec(elem,nowval)

rec(1,0)

res = [str(dic3[i-1]) for i in range(1,N+1)]

print((' '.join(res)))

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

sys.setrecursionlimit(1000000)

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

abpx = list(map(int,read().split()))

ab = iter(abpx[:N+N-2])

px = iter(abpx[N+N-2:])

dic = {}

dic2=[0]*(N+1)

dic3=[0]*N



for i in range(N):

    dic[i+1] = []

for a,b in zip(ab,ab):

    dic[a].append(b)

    dic[b].append(a)

for p,x in zip(px,px):

    dic2[p] += x

def rec(now_node,prevval):

    nowval = prevval + dic2[now_node]

    dic3[now_node-1] = nowval

    tg_list = dic[now_node][:]

    for elem in tg_list:

        dic[elem].remove(now_node)

        rec(elem,nowval)

rec(1,0)

res = [str(dic3[i-1]) for i in range(1,N+1)]

print((' '.join(res)))

import sys

input = sys.stdin.readline
sys.setrecursionlimit(1000000)
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)]
dic = {}
dic2 = [0] * (N + 1)
dic3 = [0] * N
for i in range(N):
    dic[i + 1] = []
for i in range(N - 1):
    tmp1 = ab[i][0]
    tmp2 = ab[i][1]
    dic[tmp1].append(tmp2)
    dic[tmp2].append(tmp1)
ab = 0
for i in range(Q):
    dic2[px[i][0]] += px[i][1]
px = 0


def rec(now_node, prevval):
    nowval = prevval + dic2[now_node]
    dic3[now_node - 1] = nowval
    tg_list = dic[now_node][:]
    for elem in tg_list:
        dic[elem].remove(now_node)
        rec(elem, nowval)


rec(1, 0)
res = [str(dic3[i - 1]) for i in range(1, N + 1)]
print((" ".join(res)))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(1000000)
N, Q = list(map(int, readline().split()))
abpx = list(map(int, read().split()))
ab = iter(abpx[: N + N - 2])
px = iter(abpx[N + N - 2 :])
dic = {}
dic2 = [0] * (N + 1)
dic3 = [0] * N
for i in range(N):
    dic[i + 1] = []
for a, b in zip(ab, ab):
    dic[a].append(b)
    dic[b].append(a)
for p, x in zip(px, px):
    dic2[p] += x


def rec(now_node, prevval):
    nowval = prevval + dic2[now_node]
    dic3[now_node - 1] = nowval
    tg_list = dic[now_node][:]
    for elem in tg_list:
        dic[elem].remove(now_node)
        rec(elem, nowval)


rec(1, 0)
res = [str(dic3[i - 1]) for i in range(1, N + 1)]
print((" ".join(res)))

-input = sys.stdin.readline +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.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)] +N, Q = list(map(int, readline().split())) +abpx = list(map(int, read().split())) +ab = iter(abpx[: N + N - 2]) +px = iter(abpx[N + N - 2 :]) -for i in range(N - 1): -    tmp1 = ab[i][0] -    tmp2 = ab[i][1] -    dic[tmp1].append(tmp2) -    dic[tmp2].append(tmp1) -ab = 0 -for i in range(Q): -    dic2[px[i][0]] += px[i][1] -px = 0 +for a, b in zip(ab, ab): +    dic[a].append(b) +    dic[b].append(a) +for p, x in zip(px, px): +    dic2[p] += x