from collections import deque

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

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

count = [0]*N

for i in range(N-1):

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

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

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

for i in range(Q):

    p,x = list(map(int, input().split()))

    count[p-1]+=x

q = deque([0])

flag = [False]*N

while q:

    v = q.pop()

    flag[v] = True

    for w in G[v]:

        if flag[w]:

            continue

        count[w]+=count[v]

        q.append(w)

print((*count))

import sys, copy, math, heapq, bisect

from itertools import accumulate

from collections import deque, defaultdict, Counter

input = sys.stdin.readline # 文字列の入力のとき'/n'まで受け取るので注意!!!

sys.setrecursionlimit(500000)



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

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

for i in range(N-1):

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

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

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



C = [0]*N

for q in range(Q):

    p,x = list(map(int,input().split()))

    C[p-1] += x

visited = [0]*N

def dfs(i):

    visited[i] = 1

    for k in d[i]:

        if visited[k]==1:

            continue

        C[k]+=C[i]

        dfs(k)

dfs(0)

print((*C))

from collections import deque

N, Q = list(map(int, input().split()))
G = [[] for _ in range(N)]
count = [0] * N
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
for i in range(Q):
    p, x = list(map(int, input().split()))
    count[p - 1] += x
q = deque([0])
flag = [False] * N
while q:
    v = q.pop()
    flag[v] = True
    for w in G[v]:
        if flag[w]:
            continue
        count[w] += count[v]
        q.append(w)
print((*count))

import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter

input = sys.stdin.readline  # 文字列の入力のとき'/n'まで受け取るので注意!!!
sys.setrecursionlimit(500000)
N, Q = list(map(int, input().split()))
d = [[] for i in range(N)]
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    d[a - 1].append(b - 1)
    d[b - 1].append(a - 1)
C = [0] * N
for q in range(Q):
    p, x = list(map(int, input().split()))
    C[p - 1] += x
visited = [0] * N


def dfs(i):
    visited[i] = 1
    for k in d[i]:
        if visited[k] == 1:
            continue
        C[k] += C[i]
        dfs(k)


dfs(0)
print((*C))

-from collections import deque +import sys, copy, math, heapq, bisect +from itertools import accumulate +from collections import deque, defaultdict, Counter +input = sys.stdin.readline  # 文字列の入力のとき'/n'まで受け取るので注意!!! +sys.setrecursionlimit(500000) -G = [[] for _ in range(N)] -count = [0] * N +d = [[] for i in range(N)] -    G[a - 1].append(b - 1) -    G[b - 1].append(a - 1) -for i in range(Q): +    d[a - 1].append(b - 1) +    d[b - 1].append(a - 1) +C = [0] * N +for q in range(Q): -    count[p - 1] += x -q = deque([0]) -flag = [False] * N -while q: -    v = q.pop() -    flag[v] = True -    for w in G[v]: -        if flag[w]: +    C[p - 1] += x +visited = [0] * N + + +def dfs(i): +    visited[i] = 1 +    for k in d[i]: +        if visited[k] == 1: -        count[w] += count[v] -        q.append(w) -print((*count)) +        C[k] += C[i] +        dfs(k) + + +dfs(0) +print((*C))