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

tree = [[0] * 1 for i in range(N)]


tree_list = [0] * N
end = [0] * N

for index in range(N - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    tree[a].append(b)
    tree[b].append(a)

for index in range(Q):
    a, b = map(int, input().split())
    a -= 1
    tree_list[a] += b


def iter(node):
    end[node] = -1
    child = tree[node]
    for c in child:
        if end[c] == 0:
            tree_list[c] += tree_list[node]
            iter(c)


iter(0)

print(*tree_list)


Fixed submission:
import sys

sys.setrecursionlimit(10000000)
input = sys.stdin.readline

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

tree = [[0] * 1 for i in range(N)]


tree_list = [0] * N
end = [0] * N

for index in range(N - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    tree[a].append(b)
    tree[b].append(a)

for index in range(Q):
    a, b = map(int, input().split())
    a -= 1
    tree_list[a] += b


def iter(node):
    end[node] = -1
    child = tree[node]
    for c in child:
        if end[c] == 0:
            tree_list[c] += tree_list[node]
            iter(c)


iter(0)

print(*tree_list)

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

tree = [[0] for i in range(N)]


tree_list = [0] * N
end = [0] * N

for index in range(N - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    tree[a].append(b)
    tree[b].append(a)

for index in range(Q):
    a, b = map(int, input().split())
    a -= 1
    tree_list[a] += b


def iter(node):
    end[node] = -1
    child = tree[node]
    for c in child:
        if end[c] == 0:
            tree_list[c] += tree_list[node]
            iter(c)


iter(0)

print(*tree_list)


Fixed submission:
import sys

sys.setrecursionlimit(10000000)
input = sys.stdin.readline

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

tree = [[0] * 1 for i in range(N)]


tree_list = [0] * N
end = [0] * N

for index in range(N - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    tree[a].append(b)
    tree[b].append(a)

for index in range(Q):
    a, b = map(int, input().split())
    a -= 1
    tree_list[a] += b


def iter(node):
    end[node] = -1
    child = tree[node]
    for c in child:
        if end[c] == 0:
            tree_list[c] += tree_list[node]
            iter(c)


iter(0)

print(*tree_list)

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

tree = [[] for i in range(N)]


tree_list = [0] * N
end = [0] * N

for index in range(N - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    tree[a].append(b)
    tree[b].append(a)

for index in range(Q):
    a, b = map(int, input().split())
    a -= 1
    tree_list[a] += b


def iter(node):
    end[node] = -1
    child = tree[node]
    for c in child:
        if end[c] == 0:
            tree_list[c] += tree_list[node]
            iter(c)


iter(0)

print(*tree_list)


Fixed submission:
import sys

sys.setrecursionlimit(10000000)
input = sys.stdin.readline

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

tree = [[0] * 1 for i in range(N)]


tree_list = [0] * N
end = [0] * N

for index in range(N - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    tree[a].append(b)
    tree[b].append(a)

for index in range(Q):
    a, b = map(int, input().split())
    a -= 1
    tree_list[a] += b


def iter(node):
    end[node] = -1
    child = tree[node]
    for c in child:
        if end[c] == 0:
            tree_list[c] += tree_list[node]
            iter(c)


iter(0)

print(*tree_list)

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

tree = [[] for i in range(N)]


tree_list = [0] * N
for index in range(N - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    tree[a].append(b)

for index in range(Q):
    a, b = map(int, input().split())
    a -= 1
    tree_list[a] += b


def iter(node):
    child = tree[node]
    for c in child:
        tree_list[c] += tree_list[node]
        iter(c)


iter(0)

print(*tree_list)


Fixed submission:
import sys

sys.setrecursionlimit(10000000)
input = sys.stdin.readline

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

tree = [[0] * 1 for i in range(N)]


tree_list = [0] * N
end = [0] * N

for index in range(N - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    tree[a].append(b)
    tree[b].append(a)

for index in range(Q):
    a, b = map(int, input().split())
    a -= 1
    tree_list[a] += b


def iter(node):
    end[node] = -1
    child = tree[node]
    for c in child:
        if end[c] == 0:
            tree_list[c] += tree_list[node]
            iter(c)


iter(0)

print(*tree_list)