Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())

graph_lis = [[] for i in range(N)]
for n in range(N - 1):
    a, b = map(int, input().split())
    a, b = min(a, b), max(a, b)
    graph_lis[b - 1].append(a - 1)

ans_list = [0] * N

points = [0] * N
for q in range(Q):
    p, x = map(int, input().split())
    points[p - 1] += x

ans_list[0] = points[0]
for n in range(1, N):
    ans_list[n] = ans_list[graph_lis[n][0]] + points[n]
print(' '.join(map(str, ans_list)))

Fixed submission:
from collections import deque

N, Q = map(int, input().split())
graph_lis = [[] for n in range(N)]

for i in range(N - 1):
    a, b = map(int, input().split())
    graph_lis[a - 1].append(b - 1)
    graph_lis[b - 1].append(a - 1)

ans = [0] * N
for q in range(Q):
    p, x = map(int, input().split())
    ans[p - 1] += x

deq = deque([0])
visited = [False] * N
while deq:
    parent = deq.popleft()
    edge = graph_lis[parent]
    for v in edge:
        if not visited[v]:
            ans[v] += ans[parent]
            deq.append(v)
    visited[parent] = True
print(*ans)

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())

graph_lis = [[] for i in range(N)]
for n in range(N - 1):
    a, b = map(int, input().split())
    graph_lis[b - 1].append(a - 1)

ans_list = [0] * N

points = [0] * N
for q in range(Q):
    p, x = map(int, input().split())
    points[p - 1] += x

ans_list[0] = points[0]
for n in range(1, N):
    ans_list[n] = ans_list[graph_lis[n][0]] + points[n]
print(' '.join(map(str, ans_list)))

Fixed submission:
from collections import deque

N, Q = map(int, input().split())
graph_lis = [[] for n in range(N)]

for i in range(N - 1):
    a, b = map(int, input().split())
    graph_lis[a - 1].append(b - 1)
    graph_lis[b - 1].append(a - 1)

ans = [0] * N
for q in range(Q):
    p, x = map(int, input().split())
    ans[p - 1] += x

deq = deque([0])
visited = [False] * N
while deq:
    parent = deq.popleft()
    edge = graph_lis[parent]
    for v in edge:
        if not visited[v]:
            ans[v] += ans[parent]
            deq.append(v)
    visited[parent] = True
print(*ans)

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())

graph_lis = [[] for i in range(N)]
for n in range(N - 1):
    a, b = map(int, input().split())
    graph_lis[b - 1].append(a - 1)

ans_list = [0] * N

points = [0] * N
for q in range(Q):
    p, x = map(int, input().split())
    points[p - 1] += x

ans_list[0] = points[0]
for n in range(1, N):
    ans_list[n] = ans_list[graph_lis[n][0]] + points[n]
print(*ans_list)

Fixed submission:
from collections import deque

N, Q = map(int, input().split())
graph_lis = [[] for n in range(N)]

for i in range(N - 1):
    a, b = map(int, input().split())
    graph_lis[a - 1].append(b - 1)
    graph_lis[b - 1].append(a - 1)

ans = [0] * N
for q in range(Q):
    p, x = map(int, input().split())
    ans[p - 1] += x

deq = deque([0])
visited = [False] * N
while deq:
    parent = deq.popleft()
    edge = graph_lis[parent]
    for v in edge:
        if not visited[v]:
            ans[v] += ans[parent]
            deq.append(v)
    visited[parent] = True
print(*ans)

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())

graph_lis = [[] for i in range(N)]
for n in range(N - 1):#0-originedに注意
    a, b = map(int, input().split())
    graph_lis[b - 1].append(a - 1)

#print(graph_lis)

ans_list = [0] * N

points = [0] * N
for q in range(Q):
    p, x = map(int, input().split())
    # start from p - 1
    points[p - 1] += x

ans_list[0] = points[0]
for n in range(1, N):
    ans_list[n] = ans_list[graph_lis[n][0]] + points[n]
print(*ans_list)

Fixed submission:
from collections import deque

N, Q = map(int, input().split())
graph_lis = [[] for n in range(N)]

for i in range(N - 1):
    a, b = map(int, input().split())
    graph_lis[a - 1].append(b - 1)
    graph_lis[b - 1].append(a - 1)

ans = [0] * N
for q in range(Q):
    p, x = map(int, input().split())
    ans[p - 1] += x

deq = deque([0])
visited = [False] * N
while deq:
    parent = deq.popleft()
    edge = graph_lis[parent]
    for v in edge:
        if not visited[v]:
            ans[v] += ans[parent]
            deq.append(v)
    visited[parent] = True
print(*ans)