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

edge=[[] for i in range(n)]

for i in range(n-1):

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

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



base_score = [0]*n

for i in range(q):

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

    base_score[p-1] += x

    

score=[0]*n



for i,bs in enumerate(base_score):

    score[i] = bs

    for j in edge[i]:

        base_score[j] += bs



print((*score))
n,q,*abpx=list(map(int,open(0).read().split()))

edge=[[] for i in range(n)]

for a,b in zip(abpx[:-2*q:2],abpx[1:-2*q:2]):

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

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



base_score = [0]*n

for p,x in zip(abpx[-2*q::2],abpx[-2*q+1::2]):

    base_score[p-1] += x

    

score=[0]*n

check=[0]*n

update_n=[0]

check[0] = 1

while update_n:

    current_n = update_n.pop()

    score[current_n] = base_score[current_n]

    for next_n in edge[current_n]:

        if check[next_n]:

            continue

        else:

            check[next_n] = 1

            base_score[next_n] += base_score[current_n]

            update_n += next_n,



print((*score))
n, q = list(map(int, input().split()))
edge = [[] for i in range(n)]
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    edge[a - 1].append(b - 1)
base_score = [0] * n
for i in range(q):
    p, x = list(map(int, input().split()))
    base_score[p - 1] += x
score = [0] * n
for i, bs in enumerate(base_score):
    score[i] = bs
    for j in edge[i]:
        base_score[j] += bs
print((*score))

n, q, *abpx = list(map(int, open(0).read().split()))
edge = [[] for i in range(n)]
for a, b in zip(abpx[: -2 * q : 2], abpx[1 : -2 * q : 2]):
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)
base_score = [0] * n
for p, x in zip(abpx[-2 * q :: 2], abpx[-2 * q + 1 :: 2]):
    base_score[p - 1] += x
score = [0] * n
check = [0] * n
update_n = [0]
check[0] = 1
while update_n:
    current_n = update_n.pop()
    score[current_n] = base_score[current_n]
    for next_n in edge[current_n]:
        if check[next_n]:
            continue
        else:
            check[next_n] = 1
            base_score[next_n] += base_score[current_n]
            update_n += (next_n,)
print((*score))

-n, q = list(map(int, input().split())) +n, q, *abpx = list(map(int, open(0).read().split())) -for i in range(n - 1): -    a, b = list(map(int, input().split())) +for a, b in zip(abpx[: -2 * q : 2], abpx[1 : -2 * q : 2]): +    edge[b - 1].append(a - 1) -for i in range(q): -    p, x = list(map(int, input().split())) +for p, x in zip(abpx[-2 * q :: 2], abpx[-2 * q + 1 :: 2]): -for i, bs in enumerate(base_score): -    score[i] = bs -    for j in edge[i]: -        base_score[j] += bs +check = [0] * n +update_n = [0] +check[0] = 1 +while update_n: +    current_n = update_n.pop() +    score[current_n] = base_score[current_n] +    for next_n in edge[current_n]: +        if check[next_n]: +            continue +        else: +            check[next_n] = 1 +            base_score[next_n] += base_score[current_n] +            update_n += (next_n,)