from sys import stdin

import sys

from itertools import groupby

sys.setrecursionlimit(10**6) 

n,q = [int(x) for x in stdin.readline().rstrip().split()]

li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n-1)]

lin = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]



kazu = [[]for _ in range(n)]

point = [0]*n



for i in range(len(li)):

    kazu[li[i][0]-1].append(li[i][1]-1)

    kazu[li[i][1]-1].append(li[i][0]-1)

for i in range(q):

    point[lin[i][0]-1] += lin[i][1]



def dfs(li,li2,now,before):

    for i in (li[now]):

        if i == before:

            continue

        li2[i] += li2[now]

        dfs(kazu,point,i,now)

dfs(kazu,point,0,-1)

print((*point))
import sys

sys.setrecursionlimit(10 ** 6)

import sys

def input():

    return sys.stdin.readline()[:-1]

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

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

point = [0] * N

for _ in range(N - 1):

    a , b = list(map(int,input().split()))

    graph[a - 1].append(b - 1)

    graph[b - 1].append(a - 1)

#print(graph)

for _ in range(Q):

    a , b = list(map(int,input().split()))

    a = a - 1

    point[a] += b

# dfsを用いて累積和を計算する

# 初期状態だと前の値がないためデフォルト引数に-1を代入

def dfs(now , prev = -1):

    for next in graph[now]:

        # 次のノードが前に参照した値の時はcontinue

        if next == prev:

            continue

        # 現在の値を次のポイントに加算することで累積和をとる

        point[next] += point[now]

        # 次のノードと現在のノードを引数にdfsを継続する

        dfs(next , now)



dfs(0)

print((*point))
from sys import stdin
import sys
from itertools import groupby

sys.setrecursionlimit(10**6)
n, q = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int, stdin.readline().rstrip().split())) for _ in range(n - 1)]
lin = [list(map(int, stdin.readline().rstrip().split())) for _ in range(q)]
kazu = [[] for _ in range(n)]
point = [0] * n
for i in range(len(li)):
    kazu[li[i][0] - 1].append(li[i][1] - 1)
    kazu[li[i][1] - 1].append(li[i][0] - 1)
for i in range(q):
    point[lin[i][0] - 1] += lin[i][1]


def dfs(li, li2, now, before):
    for i in li[now]:
        if i == before:
            continue
        li2[i] += li2[now]
        dfs(kazu, point, i, now)


dfs(kazu, point, 0, -1)
print((*point))

import sys

sys.setrecursionlimit(10**6)
import sys


def input():
    return sys.stdin.readline()[:-1]


N, Q = list(map(int, input().split()))
graph = [[] for _ in range(N)]
point = [0] * N
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
# print(graph)
for _ in range(Q):
    a, b = list(map(int, input().split()))
    a = a - 1
    point[a] += b
# dfsを用いて累積和を計算する
# 初期状態だと前の値がないためデフォルト引数に-1を代入
def dfs(now, prev=-1):
    for next in graph[now]:
        # 次のノードが前に参照した値の時はcontinue
        if next == prev:
            continue
        # 現在の値を次のポイントに加算することで累積和をとる
        point[next] += point[now]
        # 次のノードと現在のノードを引数にdfsを継続する
        dfs(next, now)


dfs(0)
print((*point))

-from sys import stdin -from itertools import groupby -n, q = [int(x) for x in stdin.readline().rstrip().split()] -li = [list(map(int, stdin.readline().rstrip().split())) for _ in range(n - 1)] -lin = [list(map(int, stdin.readline().rstrip().split())) for _ in range(q)] -kazu = [[] for _ in range(n)] -point = [0] * n -for i in range(len(li)): -    kazu[li[i][0] - 1].append(li[i][1] - 1) -    kazu[li[i][1] - 1].append(li[i][0] - 1) -for i in range(q): -    point[lin[i][0] - 1] += lin[i][1] +import sys -def dfs(li, li2, now, before): -    for i in li[now]: -        if i == before: -            continue -        li2[i] += li2[now] -        dfs(kazu, point, i, now) +def input(): +    return sys.stdin.readline()[:-1] -dfs(kazu, point, 0, -1) +N, Q = list(map(int, input().split())) +graph = [[] for _ in range(N)] +point = [0] * N +for _ in range(N - 1): +    a, b = list(map(int, input().split())) +    graph[a - 1].append(b - 1) +    graph[b - 1].append(a - 1) +# print(graph) +for _ in range(Q): +    a, b = list(map(int, input().split())) +    a = a - 1 +    point[a] += b +# dfsを用いて累積和を計算する +# 初期状態だと前の値がないためデフォルト引数に-1を代入 +def dfs(now, prev=-1): +    for next in graph[now]: +        # 次のノードが前に参照した値の時はcontinue +        if next == prev: +            continue +        # 現在の値を次のポイントに加算することで累積和をとる +        point[next] += point[now] +        # 次のノードと現在のノードを引数にdfsを継続する +        dfs(next, now) + + +dfs(0)