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



adj = [list() for _ in range(N)]

for _ in range(N-1):

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

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



memo = [0]*N

for _ in range(Q):

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

    memo[p-1] += x



result = [None]*N

stack = [(0,0)]

while stack:

    v,a = stack.pop()

    a += memo[v]

    result[v] = a

    for u in adj[v]:

        stack.append((u,a))



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



adj = [list() for _ in range(N)]

for _ in range(N-1):

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

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

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



memo = [0]*N

for _ in range(Q):

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

    memo[p-1] += x



result = [0]*N

stack = [(None,0)]

while stack:

    p,v = stack.pop()

    result[v] += memo[v]

    for u in adj[v]:

        if u == p:

            continue

        result[u] += result[v]

        stack.append((v,u))



print((*result))
N, Q = list(map(int, input().split()))
adj = [list() for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    adj[a - 1].append(b - 1)
memo = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    memo[p - 1] += x
result = [None] * N
stack = [(0, 0)]
while stack:
    v, a = stack.pop()
    a += memo[v]
    result[v] = a
    for u in adj[v]:
        stack.append((u, a))
print((*result))

N, Q = list(map(int, input().split()))
adj = [list() for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    adj[a - 1].append(b - 1)
    adj[b - 1].append(a - 1)
memo = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    memo[p - 1] += x
result = [0] * N
stack = [(None, 0)]
while stack:
    p, v = stack.pop()
    result[v] += memo[v]
    for u in adj[v]:
        if u == p:
            continue
        result[u] += result[v]
        stack.append((v, u))
print((*result))

+    adj[b - 1].append(a - 1) -result = [None] * N -stack = [(0, 0)] +result = [0] * N +stack = [(None, 0)] -    v, a = stack.pop() -    a += memo[v] -    result[v] = a +    p, v = stack.pop() +    result[v] += memo[v] -        stack.append((u, a)) +        if u == p: +            continue +        result[u] += result[v] +        stack.append((v, u))