Buggy python submission (verdict: Runtime Error):
import sys

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

points = [[] for _ in range(N)]
counters = [0 for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    points[a - 1].append(b)

operations = []
for _ in range(Q):
    operations.append(list(map(int, input().split())))

# print(points)
# print(operations)


def dfs(points, counters, i, count):
    counters[i - 1] += count
    for next_point in points[i - 1]:
        dfs(points, counters, next_point, count)


for operation in operations:
    dfs(points, counters, operation[0], operation[1])
# print(counters)

print(' '.join(map(str, counters)))


Fixed submission:
import sys
input = sys.stdin.readline

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

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

# print(graph)
v = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    v[p - 1] += x
# print(v)


seen_points = [True] * N
seen_points[0] = False
stack = [0]

while stack:
    now = stack.pop()
    for i in graph[now]:
        if seen_points[i]:
            seen_points[i] = False
            stack.append(i)
            v[i] += v[now]

print(*v)

Buggy python submission (verdict: Runtime Error):
import sys

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

points = [[] for _ in range(N)]
counters = [0 for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    points[a - 1].append(b)

operations = []
for _ in range(Q):
    operations.append(list(map(int, input().split())))

# print(points)
# print(operations)


def dfs(points, counters, i, count):
    counters[i - 1] += count
    for next_point in points[i - 1]:
        dfs(points, counters, next_point, count)


for operation in operations:
    dfs(points, counters, operation[0], operation[1])
# print(counters)

print(' '.join(map(str, counters)))


Fixed submission:
import sys
input = sys.stdin.readline

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

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

# print(graph)
v = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    v[p - 1] += x
# print(v)


seen_points = [True] * N
seen_points[0] = False
stack = [0]

while stack:
    now = stack.pop()
    for i in graph[now]:
        if seen_points[i]:
            seen_points[i] = False
            stack.append(i)
            v[i] += v[now]

print(*v)

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

points = [[] for _ in range(N)]
counters = [0 for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    points[a - 1].append(b)

operations = []
for _ in range(Q):
    operations.append(list(map(int, input().split())))

# print(points)
# print(operations)


def dfs(points, counters, i, count):
    counters[i - 1] += count
    for next_point in points[i - 1]:
        dfs(points, counters, next_point, count)


for operation in operations:
    dfs(points, counters, operation[0], operation[1])
# print(counters)

print(' '.join(map(str, counters)))


Fixed submission:
import sys
input = sys.stdin.readline

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

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

# print(graph)
v = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    v[p - 1] += x
# print(v)


seen_points = [True] * N
seen_points[0] = False
stack = [0]

while stack:
    now = stack.pop()
    for i in graph[now]:
        if seen_points[i]:
            seen_points[i] = False
            stack.append(i)
            v[i] += v[now]

print(*v)