from collections import deque

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

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

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

for i in range(N-1):

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

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

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

#points=[tuple(map(int,input().split())) for _ in range(Q)]

score=[0]*N

for i in range(Q):

    point,sc=map(int,input().split())

    score[point-1]=score[point-1]+sc

#print(points)

v=0

d=deque()

d.append(v)

seen=[0]*N

seen[0]=1

ans=[0]*N

while len(d)!=0:

    v=d.popleft()

    for j in nondirtree[v]:

        if seen[j]==0:

            dirtree[v].append(j)

            seen[j]=1

            d.append(j)

    #print(d,seen,dirtree)

    #input(

v=0

d=deque()

d.append(v)

#print(dirtree)

ans[0]=score[0]

while len(d)!=0:

    v=d.popleft()

    for j in dirtree[v]:

        ans[j]=ans[v]+score[j]

        d.append(j)

    #input()

    #print(ans)

print(*ans,sep=" ")

import sys

input=sys.stdin.readline

from collections import deque

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

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

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

for i in range(N-1):

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

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

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

#points=[tuple(map(int,input().split())) for _ in range(Q)]

score=[0]*N

for i in range(Q):

    point,sc=map(int,input().split())

    score[point-1]=score[point-1]+sc

#print(points)

v=0

d=deque()

d.append(v)

seen=[0]*N

seen[0]=1

ans=[0]*N

while len(d)!=0:

    v=d.popleft()

    for j in nondirtree[v]:

        if seen[j]==0:

            dirtree[v].append(j)

            seen[j]=1

            d.append(j)

    #print(d,seen,dirtree)

    #input(

v=0

d=deque()

d.append(v)

#print(dirtree)

ans[0]=score[0]

while len(d)!=0:

    v=d.popleft()

    for j in dirtree[v]:

        ans[j]=ans[v]+score[j]

        d.append(j)

    #input()

    #print(ans)

print(*ans,sep=" ")

from collections import deque

N, Q = map(int, input().split())
nondirtree = [[] for _ in range(N)]
dirtree = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    nondirtree[a - 1].append(b - 1)
    nondirtree[b - 1].append(a - 1)
# points=[tuple(map(int,input().split())) for _ in range(Q)]
score = [0] * N
for i in range(Q):
    point, sc = map(int, input().split())
    score[point - 1] = score[point - 1] + sc
# print(points)
v = 0
d = deque()
d.append(v)
seen = [0] * N
seen[0] = 1
ans = [0] * N
while len(d) != 0:
    v = d.popleft()
    for j in nondirtree[v]:
        if seen[j] == 0:
            dirtree[v].append(j)
            seen[j] = 1
            d.append(j)
    # print(d,seen,dirtree)
    # input(
v = 0
d = deque()
d.append(v)
# print(dirtree)
ans[0] = score[0]
while len(d) != 0:
    v = d.popleft()
    for j in dirtree[v]:
        ans[j] = ans[v] + score[j]
        d.append(j)
    # input()
    # print(ans)
print(*ans, sep=" ")

import sys

input = sys.stdin.readline
from collections import deque

N, Q = map(int, input().split())
nondirtree = [[] for _ in range(N)]
dirtree = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    nondirtree[a - 1].append(b - 1)
    nondirtree[b - 1].append(a - 1)
# points=[tuple(map(int,input().split())) for _ in range(Q)]
score = [0] * N
for i in range(Q):
    point, sc = map(int, input().split())
    score[point - 1] = score[point - 1] + sc
# print(points)
v = 0
d = deque()
d.append(v)
seen = [0] * N
seen[0] = 1
ans = [0] * N
while len(d) != 0:
    v = d.popleft()
    for j in nondirtree[v]:
        if seen[j] == 0:
            dirtree[v].append(j)
            seen[j] = 1
            d.append(j)
    # print(d,seen,dirtree)
    # input(
v = 0
d = deque()
d.append(v)
# print(dirtree)
ans[0] = score[0]
while len(d) != 0:
    v = d.popleft()
    for j in dirtree[v]:
        ans[j] = ans[v] + score[j]
        d.append(j)
    # input()
    # print(ans)
print(*ans, sep=" ")

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