n,qq = list(map(int,input().split()))



g = [[] for _ in range(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)





l = [0]*n

count = [0]*n



for _ in range(qq):

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

    l[p-1] += x



p = [True]*n

p[0] = False





q = [0]



while q:

    v = q.pop()

    for w in g[v]:

        if p[w]:

            p[w] = False

            l[w] += l[v]

            q.append(w)



print((*l))
import sys

sys.setrecursionlimit(10 ** 7)

input = sys.stdin.readline



n, q = list(map(int, input().split()))



g = [[] for _ in range(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)



l = [0]*n



for _ in range(q):

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

    l[p-1] += x



visited = [False]*n

visited[0] = True



q = [0]



while q:

    v = q.pop()

    for w in g[v]:

        if not visited[w]:

            visited[w] = True

            l[w] += l[v]

            q.append(w)



print((*l))

n, qq = list(map(int, input().split()))
g = [[] for _ in range(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)
l = [0] * n
count = [0] * n
for _ in range(qq):
    p, x = list(map(int, input().split()))
    l[p - 1] += x
p = [True] * n
p[0] = False
q = [0]
while q:
    v = q.pop()
    for w in g[v]:
        if p[w]:
            p[w] = False
            l[w] += l[v]
            q.append(w)
print((*l))

import sys

sys.setrecursionlimit(10**7)
input = sys.stdin.readline
n, q = list(map(int, input().split()))
g = [[] for _ in range(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)
l = [0] * n
for _ in range(q):
    p, x = list(map(int, input().split()))
    l[p - 1] += x
visited = [False] * n
visited[0] = True
q = [0]
while q:
    v = q.pop()
    for w in g[v]:
        if not visited[w]:
            visited[w] = True
            l[w] += l[v]
            q.append(w)
print((*l))

-n, qq = list(map(int, input().split())) +import sys + +sys.setrecursionlimit(10**7) +input = sys.stdin.readline +n, q = list(map(int, input().split())) -count = [0] * n -for _ in range(qq): +for _ in range(q): -p = [True] * n -p[0] = False +visited = [False] * n +visited[0] = True -        if p[w]: -            p[w] = False +        if not visited[w]: +            visited[w] = True