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

G=[[] for i 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)

c=[0]*n

for i in range(q):

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

  c[p-1]+=x

from collections import deque

visited=[-1]*n

q=deque()

q.append(0)

while q:

  cur=q.popleft()

  visited[cur]=0

  for nx in G[cur]:

    if visited[nx]!=-1:continue

    c[nx]+=c[cur]

    q.append(nx)

print((*c))

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)



counter = [0]*N

for i in range(Q):

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

    counter[p-1] += x



from collections import deque

visited = [-1]*N

q = deque()

q.append(0)



while q:

    cur = q.popleft()

    visited[cur] = 0

    for nx in G[cur]:

        if visited[nx] != -1: continue

        counter[nx] += counter[cur]

        q.append(nx)



print((*counter))











n, q = list(map(int, input().split()))
G = [[] for i 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)
c = [0] * n
for i in range(q):
    p, x = list(map(int, input().split()))
    c[p - 1] += x
from collections import deque

visited = [-1] * n
q = deque()
q.append(0)
while q:
    cur = q.popleft()
    visited[cur] = 0
    for nx in G[cur]:
        if visited[nx] != -1:
            continue
        c[nx] += c[cur]
        q.append(nx)
print((*c))

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)
counter = [0] * N
for i in range(Q):
    p, x = list(map(int, input().split()))
    counter[p - 1] += x
from collections import deque

visited = [-1] * N
q = deque()
q.append(0)
while q:
    cur = q.popleft()
    visited[cur] = 0
    for nx in G[cur]:
        if visited[nx] != -1:
            continue
        counter[nx] += counter[cur]
        q.append(nx)
print((*counter))

-n, q = list(map(int, input().split())) -G = [[] for i in range(n)] -for i in range(n - 1): +N, Q = list(map(int, input().split())) +G = [[] for _ in range(N)] +for i in range(N - 1): -c = [0] * n -for i in range(q): +counter = [0] * N +for i in range(Q): -    c[p - 1] += x +    counter[p - 1] += x -visited = [-1] * n +visited = [-1] * N -        c[nx] += c[cur] +        counter[nx] += counter[cur] -print((*c)) +print((*counter))