Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
connect = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    connect[a].append(b)
    connect[b].append(a)
score = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    score[p] += x

def dfs(now, prev = -1):
    for nx in connect[now]:
        if nx == prev: continue
        score[nx] += score[now]
        dfs(nx, now)

dfs(0)
print(*score)

Fixed submission:
from collections import deque
 
N, Q = map(int, input().split())
Ki = [[] for _ in range(N)]
for _ in range(N-1):
    p, c = map(int, input().split())
    Ki[p-1].append(c-1)
    Ki[c-1].append(p-1)
S = [0]*N
for _ in range(Q):
    node, score = map(int, input().split())
    S[node-1] += score
 
stack = deque([0])
done = [0]*N
done[0] = 1
 
while len(stack) > 0:
    now = stack.pop()
    
    for new in Ki[now]:
        if done[new] == 0:
            done[new] = 1
            stack.append(new)
            S[new] += S[now]
    
print(*S)

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
connect = {i:set() for i in range(1, N+1)}
for _ in range(N-1):
    a, b = map(int, input().split())
    connect[a].add(b)
    connect[b].add(a)
score = {i:0 for i in range(1, N+1)}
for _ in range(Q):
    p, x = map(int, input().split())
    score[p] += x

def dfs(now, prev = -1):
    for nx in connect[now]:
        if nx == prev: continue
        score[nx] += score[now]
        dfs(nx, now)

dfs(1)
print(*score.values())

Fixed submission:
from collections import deque
 
N, Q = map(int, input().split())
Ki = [[] for _ in range(N)]
for _ in range(N-1):
    p, c = map(int, input().split())
    Ki[p-1].append(c-1)
    Ki[c-1].append(p-1)
S = [0]*N
for _ in range(Q):
    node, score = map(int, input().split())
    S[node-1] += score
 
stack = deque([0])
done = [0]*N
done[0] = 1
 
while len(stack) > 0:
    now = stack.pop()
    
    for new in Ki[now]:
        if done[new] == 0:
            done[new] = 1
            stack.append(new)
            S[new] += S[now]
    
print(*S)

Buggy python submission (verdict: Runtime Error):
N,Q = (int(x) for x in input().split())
connection ={i:set() for i in range(1,N+1)}
for i in range(N-1):
    a,b = (int(x) for x in input().split())
    connection[a].add(b)
    connection[b].add(a)
#point =OrderedDict({i:0 for i in range(1,N+1)})
point ={i:0 for i in range(1,N+1)}
for i in range(Q):
    p,x = (int(x) for x in input().split())
    point[p] +=x
 
def DFS(now,prev = -1):
    for next in connection[now]:
        if next == prev:
            continue
        point[next] +=point[now] 
        DFS(next,now)
 
DFS(1)
print(*point.values())

Fixed submission:
from collections import deque
 
N, Q = map(int, input().split())
Ki = [[] for _ in range(N)]
for _ in range(N-1):
    p, c = map(int, input().split())
    Ki[p-1].append(c-1)
    Ki[c-1].append(p-1)
S = [0]*N
for _ in range(Q):
    node, score = map(int, input().split())
    S[node-1] += score
 
stack = deque([0])
done = [0]*N
done[0] = 1
 
while len(stack) > 0:
    now = stack.pop()
    
    for new in Ki[now]:
        if done[new] == 0:
            done[new] = 1
            stack.append(new)
            S[new] += S[now]
    
print(*S)

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
connect = {i:set() for i in range(1, N+1)}
for _ in range(N-1):
    a, b = map(int, input().split())
    connect[a].add(b)
    connect[b].add(a)
score = {i:0 for i in range(1, N+1)}
for _ in range(Q):
    p, x = map(int, input().split())
    score[p] += x

def dfs(now, prev = -1):
    for nx in connect[now]:
        if nx == prev: continue
        score[nx] += score[now]
        dfs(nx, now)

dfs(1)
print(*score.values())

Fixed submission:
from collections import deque
 
N, Q = map(int, input().split())
Ki = [[] for _ in range(N)]
for _ in range(N-1):
    p, c = map(int, input().split())
    Ki[p-1].append(c-1)
    Ki[c-1].append(p-1)
S = [0]*N
for _ in range(Q):
    node, score = map(int, input().split())
    S[node-1] += score
 
stack = deque([0])
done = [0]*N
done[0] = 1
 
while len(stack) > 0:
    now = stack.pop()
    
    for new in Ki[now]:
        if done[new] == 0:
            done[new] = 1
            stack.append(new)
            S[new] += S[now]
    
print(*S)

Buggy python submission (verdict: Runtime Error):
def dfs(now, prev = -1):
    for nx in connect[now]:
        if nx == prev: continue
        score[nx] += score[now]
        dfs(nx, now)

N, Q = map(int, input().split())
connect = {i:set() for i in range(1, N+1)}
for _ in range(N-1):
    a, b = map(int, input().split())
    connect[a].add(b)
    connect[b].add(a)
score = {i:0 for i in range(1, N+1)}
for _ in range(Q):
    p, x = map(int, input().split())
    score[p] += x

dfs(1)
print(*score.values())

Fixed submission:
from collections import deque
 
N, Q = map(int, input().split())
Ki = [[] for _ in range(N)]
for _ in range(N-1):
    p, c = map(int, input().split())
    Ki[p-1].append(c-1)
    Ki[c-1].append(p-1)
S = [0]*N
for _ in range(Q):
    node, score = map(int, input().split())
    S[node-1] += score
 
stack = deque([0])
done = [0]*N
done[0] = 1
 
while len(stack) > 0:
    now = stack.pop()
    
    for new in Ki[now]:
        if done[new] == 0:
            done[new] = 1
            stack.append(new)
            S[new] += S[now]
    
print(*S)