import sys

sys.setrecursionlimit(5*10**5)

input = sys.stdin.readline



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

ab=[]

for _ in range(N-1):

    ab.append(tuple(map(int, input().split())))

px=[]

for _ in range(Q):

    px.append(tuple(map(int, input().split())))



cnt=[0]*(N+1)

for el in px:

    cnt[el[0]] += el[1]

#print(cnt)





lst=[[] for _ in range(N+1)]

for el in ab:

    lst[el[0]].append(el[1])

    lst[el[1]].append(el[0])

#print(lst)



seen = [False] * (N + 1)

def dfs(n):

    seen[n] = True

    for child in lst[n]:

        if seen[child] == False:

            cnt[child]+=cnt[n]

            dfs(child)



dfs(1)

#print(cnt)

print((' '.join(list(map(str, cnt[1:])))))
import sys

sys.setrecursionlimit(5*10**5)

input = sys.stdin.readline

 

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

ab=[]

for _ in range(N-1):

    ab.append(tuple(map(int, input().split())))

px=[]

for _ in range(Q):

    px.append(tuple(map(int, input().split())))

 

cnt=[0]*(N+1)

for el in px:

    cnt[el[0]] += el[1]

#print(cnt)

 

 

lst=[[] for _ in range(N+1)]

for el in ab:

    lst[el[0]].append(el[1])

    lst[el[1]].append(el[0])

#print(lst)

 

seen = set()

def dfs(n):

    seen.add(n)

    for child in lst[n]:

        if child not in seen:

            cnt[child]+=cnt[n]

            dfs(child)

 

dfs(1)

#print(cnt)

print((' '.join(list(map(str, cnt[1:])))))
import sys

sys.setrecursionlimit(5 * 10**5)
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
ab = []
for _ in range(N - 1):
    ab.append(tuple(map(int, input().split())))
px = []
for _ in range(Q):
    px.append(tuple(map(int, input().split())))
cnt = [0] * (N + 1)
for el in px:
    cnt[el[0]] += el[1]
# print(cnt)
lst = [[] for _ in range(N + 1)]
for el in ab:
    lst[el[0]].append(el[1])
    lst[el[1]].append(el[0])
# print(lst)
seen = [False] * (N + 1)


def dfs(n):
    seen[n] = True
    for child in lst[n]:
        if seen[child] == False:
            cnt[child] += cnt[n]
            dfs(child)


dfs(1)
# print(cnt)
print((" ".join(list(map(str, cnt[1:])))))

import sys

sys.setrecursionlimit(5 * 10**5)
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
ab = []
for _ in range(N - 1):
    ab.append(tuple(map(int, input().split())))
px = []
for _ in range(Q):
    px.append(tuple(map(int, input().split())))
cnt = [0] * (N + 1)
for el in px:
    cnt[el[0]] += el[1]
# print(cnt)
lst = [[] for _ in range(N + 1)]
for el in ab:
    lst[el[0]].append(el[1])
    lst[el[1]].append(el[0])
# print(lst)
seen = set()


def dfs(n):
    seen.add(n)
    for child in lst[n]:
        if child not in seen:
            cnt[child] += cnt[n]
            dfs(child)


dfs(1)
# print(cnt)
print((" ".join(list(map(str, cnt[1:])))))

-seen = [False] * (N + 1) +seen = set() -    seen[n] = True +    seen.add(n) -        if seen[child] == False: +        if child not in seen: