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



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

for i in range(N-1):

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

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

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





ans = [0] * N

px = [0] * N

for i in range(Q):

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



    px[p-1] += x



visited = [False] * N



stack = [0]

while stack:

    i = stack.pop()

    ans[i] += px[i]

    visited[i] = True

    for j in es[i]:

        #print(i,j,es)

        if visited[j] == False:

            ans[j] += ans[i]

            stack.append(j)

    



print((*ans))


from collections import deque



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

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



for i in range(N-1):

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

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

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



ans = [0] * N

for _ in range(Q):

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

    ans[p-1] += x



checked = [False] * N

q = deque()

q.append(0)

while q:

    node = q.popleft()

    checked[node] = True

    for nxt in es[node]:

        if not checked[nxt]:

            ans[nxt] += ans[node]

            q.append(nxt)

        



print((*ans))
N, Q = list(map(int, input().split()))
es = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    es[a - 1].append(b - 1)
    es[b - 1].append(a - 1)
ans = [0] * N
px = [0] * N
for i in range(Q):
    p, x = list(map(int, input().split()))
    px[p - 1] += x
visited = [False] * N
stack = [0]
while stack:
    i = stack.pop()
    ans[i] += px[i]
    visited[i] = True
    for j in es[i]:
        # print(i,j,es)
        if visited[j] == False:
            ans[j] += ans[i]
            stack.append(j)
print((*ans))

from collections import deque

N, Q = list(map(int, input().split()))
es = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    es[a - 1].append(b - 1)
    es[b - 1].append(a - 1)
ans = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    ans[p - 1] += x
checked = [False] * N
q = deque()
q.append(0)
while q:
    node = q.popleft()
    checked[node] = True
    for nxt in es[node]:
        if not checked[nxt]:
            ans[nxt] += ans[node]
            q.append(nxt)
print((*ans))

+from collections import deque + -px = [0] * N -for i in range(Q): +for _ in range(Q): -    px[p - 1] += x -visited = [False] * N -stack = [0] -while stack: -    i = stack.pop() -    ans[i] += px[i] -    visited[i] = True -    for j in es[i]: -        # print(i,j,es) -        if visited[j] == False: -            ans[j] += ans[i] -            stack.append(j) +    ans[p - 1] += x +checked = [False] * N +q = deque() +q.append(0) +while q: +    node = q.popleft() +    checked[node] = True +    for nxt in es[node]: +        if not checked[nxt]: +            ans[nxt] += ans[node] +            q.append(nxt)