Buggy python submission (verdict: Runtime Error):
N, Q = [int(n) for n in input().split()]

tree_list = [[] for _ in range(N)]

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

#print(tree_list)

score_list = [0] * N
for j in range(Q):
    p, x = [int(n) for n in input().split()]
    score_list[p-1] += x

reached = [False] * N

def dfs(v):
    reached[v] = True

    for next_v in tree_list[v]:
        if reached[next_v] == True:
            continue

        score_list[next_v] += score_list[v]
        dfs(next_v)

dfs(0)

print(*score_list)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
N, Q = [int(n) for n in input().split()]
tree_list = [[] for _ in range(N)]

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

score_list = [0] * N
for j in range(Q):
    p, x = [int(n) for n in input().split()]
    score_list[p-1] += x

reached = [False] * N
def dfs(v):
    reached[v] = True
    for next_v in tree_list[v]:
        if reached[next_v] == True:
            continue
        score_list[next_v] += score_list[v]
        dfs(next_v)
dfs(0)
print(*score_list)

Buggy python submission (verdict: Runtime Error):
N, Q = [int(n) for n in input().split()]

tree_list = [[] for _ in range(N)]
count_list = [0] * N

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

#print(tree_list)
#print(count_list)

for j in range(Q):
    p, x = [int(n) for n in input().split()]

    def func(pn, xn):
        count_list[pn] += xn
        if not tree_list[pn]:
            return
        for k in tree_list[pn]:
            func(k, xn)

    func(p-1, x)
    
#print(count_list)

print(*count_list)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
N, Q = [int(n) for n in input().split()]
tree_list = [[] for _ in range(N)]

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

score_list = [0] * N
for j in range(Q):
    p, x = [int(n) for n in input().split()]
    score_list[p-1] += x

reached = [False] * N
def dfs(v):
    reached[v] = True
    for next_v in tree_list[v]:
        if reached[next_v] == True:
            continue
        score_list[next_v] += score_list[v]
        dfs(next_v)
dfs(0)
print(*score_list)

Buggy python submission (verdict: Runtime Error):
N, Q = [int(n) for n in input().split()]

tree_list = [[] for _ in range(N)]
count_list = [0] * N

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

#print(tree_list)
#print(count_list)

for j in range(Q):
    p, x = [int(n) for n in input().split()]

    def func(pn, xn):
        count_list[pn] += xn
        for k in tree_list[pn]:
            func(k, xn)

    func(p-1, x)
    
#print(count_list)

print(*count_list)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
N, Q = [int(n) for n in input().split()]
tree_list = [[] for _ in range(N)]

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

score_list = [0] * N
for j in range(Q):
    p, x = [int(n) for n in input().split()]
    score_list[p-1] += x

reached = [False] * N
def dfs(v):
    reached[v] = True
    for next_v in tree_list[v]:
        if reached[next_v] == True:
            continue
        score_list[next_v] += score_list[v]
        dfs(next_v)
dfs(0)
print(*score_list)

Buggy python submission (verdict: Runtime Error):
N, Q = [int(n) for n in input().split()]

tree_list = {n:[] for n in range(1, N+1)}
count_list = {n:0 for n in range(1, N+1)}

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

#print(tree_list)
#print(count_list)

def func(pn, xn):
    count_list[pn] += xn
    if not tree_list[pn]:
        return
    else:
        for k in tree_list[pn]:
            func(k, xn)

for j in range(Q):
    p, x = [int(n) for n in input().split()]
    func(p, x)
    
#print(count_list)

print(' '.join([str(v) for v in count_list.values()]))

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
N, Q = [int(n) for n in input().split()]
tree_list = [[] for _ in range(N)]

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

score_list = [0] * N
for j in range(Q):
    p, x = [int(n) for n in input().split()]
    score_list[p-1] += x

reached = [False] * N
def dfs(v):
    reached[v] = True
    for next_v in tree_list[v]:
        if reached[next_v] == True:
            continue
        score_list[next_v] += score_list[v]
        dfs(next_v)
dfs(0)
print(*score_list)

Buggy python submission (verdict: Runtime Error):
N, Q = [int(n) for n in input().split()]

tree_list = {n:[] for n in range(1, N+1)}
count_list = {n:0 for n in range(1, N+1)}

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

#print(tree_list)
#print(count_list)

def func(pn, xn):
    count_list[pn] += xn
    for k in tree_list[pn]:
        func(k, xn)

for j in range(Q):
    p, x = [int(n) for n in input().split()]
    func(p, x)
    
#print(count_list)

print(' '.join([str(v) for v in count_list.values()]))

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
N, Q = [int(n) for n in input().split()]
tree_list = [[] for _ in range(N)]

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

score_list = [0] * N
for j in range(Q):
    p, x = [int(n) for n in input().split()]
    score_list[p-1] += x

reached = [False] * N
def dfs(v):
    reached[v] = True
    for next_v in tree_list[v]:
        if reached[next_v] == True:
            continue
        score_list[next_v] += score_list[v]
        dfs(next_v)
dfs(0)
print(*score_list)

Buggy python submission (verdict: Runtime Error):
N, Q = [int(n) for n in input().split()]

tree_list = {n:[] for n in range(1, N+1)}
count_list = {n:0 for n in range(1, N+1)}

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

#print(tree_list)
#print(count_list)

def func(pn):
    count_list[pn] += x
    for k in tree_list[pn]:
        func(k)

for j in range(Q):
    p, x = [int(n) for n in input().split()]
    func(p)
    
#print(count_list)

print(' '.join([str(v) for v in count_list.values()]))

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
N, Q = [int(n) for n in input().split()]
tree_list = [[] for _ in range(N)]

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

score_list = [0] * N
for j in range(Q):
    p, x = [int(n) for n in input().split()]
    score_list[p-1] += x

reached = [False] * N
def dfs(v):
    reached[v] = True
    for next_v in tree_list[v]:
        if reached[next_v] == True:
            continue
        score_list[next_v] += score_list[v]
        dfs(next_v)
dfs(0)
print(*score_list)

Buggy python submission (verdict: Runtime Error):
N, Q = [int(n) for n in input().split()]

tree_list = {n:[] for n in range(1, N+1)}
count_list = {n:0 for n in range(1, N+1)}

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

#print(tree_list)
#print(count_list)

for j in range(Q):
    p, x = [int(n) for n in input().split()]
   
    def func(pn):
        count_list[pn] += x
        for k in tree_list[pn]:
            func(k)
    
    func(p)
    
#print(count_list)

print(' '.join([str(v) for k, v in count_list.items()]))

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
N, Q = [int(n) for n in input().split()]
tree_list = [[] for _ in range(N)]

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

score_list = [0] * N
for j in range(Q):
    p, x = [int(n) for n in input().split()]
    score_list[p-1] += x

reached = [False] * N
def dfs(v):
    reached[v] = True
    for next_v in tree_list[v]:
        if reached[next_v] == True:
            continue
        score_list[next_v] += score_list[v]
        dfs(next_v)
dfs(0)
print(*score_list)