from collections import deque

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



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



for _ in range(N - 1):

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

    

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

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



X = [0] * N



for _ in range(Q):

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

    X[p - 1] += x



d = deque([0])

ans = X

visited = [False] * N 



while d:

    q = d.pop()

    visited[q] = True



    for t in tree[q]:

        if not visited[t]:

            ans[t] += X[q]

            d.append(t)



print((*ans))
from collections import deque



def MI():

    return list(map(int, input().split()))



def LI():

    return list(map(int, input().split()))



N, Q = MI()

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



for _ in range(N - 1):

    a, b = MI()

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

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

    

plus = [0] * N



for _ in range(Q):

    p, x = MI()

    plus[p - 1] += x



queue = deque([0])

visited = [False] * N



while queue:

    u = queue.popleft()

    visited[u] = True

    

    for t in T[u]:

        if not visited[t]:

            plus[t] += plus[u]

            queue.append(t)



print((*plus))
from collections import deque

N, Q = list(map(int, input().split()))
tree = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)
X = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    X[p - 1] += x
d = deque([0])
ans = X
visited = [False] * N
while d:
    q = d.pop()
    visited[q] = True
    for t in tree[q]:
        if not visited[t]:
            ans[t] += X[q]
            d.append(t)
print((*ans))

from collections import deque


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


N, Q = MI()
T = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = MI()
    T[a - 1].append(b - 1)
    T[b - 1].append(a - 1)
plus = [0] * N
for _ in range(Q):
    p, x = MI()
    plus[p - 1] += x
queue = deque([0])
visited = [False] * N
while queue:
    u = queue.popleft()
    visited[u] = True
    for t in T[u]:
        if not visited[t]:
            plus[t] += plus[u]
            queue.append(t)
print((*plus))

-N, Q = list(map(int, input().split())) -tree = [[] for _ in range(N)] + +def MI(): +    return list(map(int, input().split())) + + +def LI(): +    return list(map(int, input().split())) + + +N, Q = MI() +T = [[] for _ in range(N)] -    a, b = list(map(int, input().split())) -    tree[a - 1].append(b - 1) -    tree[b - 1].append(a - 1) -X = [0] * N +    a, b = MI() +    T[a - 1].append(b - 1) +    T[b - 1].append(a - 1) +plus = [0] * N -    p, x = list(map(int, input().split())) -    X[p - 1] += x -d = deque([0]) -ans = X +    p, x = MI() +    plus[p - 1] += x +queue = deque([0]) -while d: -    q = d.pop() -    visited[q] = True -    for t in tree[q]: +while queue: +    u = queue.popleft() +    visited[u] = True +    for t in T[u]: -            ans[t] += X[q] -            d.append(t) -print((*ans)) +            plus[t] += plus[u] +            queue.append(t) +print((*plus))