Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
 
tree = [[i] for i in range(N+1)]
tree_parent = [[0] for i in range(N+1)]
points = [0] * N
 
for i in range(1, N):
  a, b = map(int, input().split())
  tree[a].append(b)
  tree_parent[b].append(a)  
  tree[tree_parent[a][-1]].append(b)
    
for i in range(Q):
  p, x = map(int, input().split())
  for node in tree[p]:
    points[node-1] += x
    
for point in points:
  print(point, end=" ")

Fixed submission:
n,q = map(int,input().split())
rl = [0] * n
scores = [0] * n
for i in range(n-1):
    a,b = map(int,input().split())
    rl[b-1] = a-1
for j in range(q):
    p,x = map(int,input().split())
    scores[p-1] += x
for k in range(1,n):
    scores[k] += scores[rl[k]]
print(*scores)

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())

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

for i in range(1, N):
  a, b = map(int, input().split())
  tree[a].append(b)
  tree_parent[b].append(a)  
  for parent in tree_parent[a]:
    tree[parent].append(b)
    
for i in range(Q):
  p, x = map(int, input().split())
  for node in tree[p]:
    points[node-1] += x
    
for point in points:
  print(point, end=" ")

Fixed submission:
n,q = map(int,input().split())
rl = [0] * n
scores = [0] * n
for i in range(n-1):
    a,b = map(int,input().split())
    rl[b-1] = a-1
for j in range(q):
    p,x = map(int,input().split())
    scores[p-1] += x
for k in range(1,n):
    scores[k] += scores[rl[k]]
print(*scores)

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())

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

for i in range(1, N):
  a, b = map(int, input().split())
  tree[a].add(b)
  for j in range(a):
    if a in tree[j]:
      tree[j].add(b)  

for i in range(Q):
  p, x = map(int, input().split())
  for node in tree[p]:
    points[node-1] += x
    
for point in points:
  print(point, end=" ")

Fixed submission:
n,q = map(int,input().split())
rl = [0] * n
scores = [0] * n
for i in range(n-1):
    a,b = map(int,input().split())
    rl[b-1] = a-1
for j in range(q):
    p,x = map(int,input().split())
    scores[p-1] += x
for k in range(1,n):
    scores[k] += scores[rl[k]]
print(*scores)

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())

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

for i in range(1, N):
  a, b = map(int, input().split())
  tree[a].append(b)
  for j in range(i):
    if a in tree[j]:
      tree[j].append(b)
      
for i in range(Q):
  p, x = map(int, input().split())
  for node in set(tree[p]):
    points[node-1] += x
    
for point in points:
  print(point, end=" ")

Fixed submission:
n,q = map(int,input().split())
rl = [0] * n
scores = [0] * n
for i in range(n-1):
    a,b = map(int,input().split())
    rl[b-1] = a-1
for j in range(q):
    p,x = map(int,input().split())
    scores[p-1] += x
for k in range(1,n):
    scores[k] += scores[rl[k]]
print(*scores)

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())

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

for i in range(1, N):
  a, b = map(int, input().split())
  tree[a].add(b)
  for j in range(i):
    if a in tree[j]:
      tree[j].add(b)
      
for i in range(Q):
  p, x = map(int, input().split())
  for node in tree[p]:
    points[node-1] += x

# print(tree)
    
for point in points:
  print(point, end=" ")

Fixed submission:
n,q = map(int,input().split())
rl = [0] * n
scores = [0] * n
for i in range(n-1):
    a,b = map(int,input().split())
    rl[b-1] = a-1
for j in range(q):
    p,x = map(int,input().split())
    scores[p-1] += x
for k in range(1,n):
    scores[k] += scores[rl[k]]
print(*scores)

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

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

for i in range(1, N):
  a, b = map(int, input().split())
  # print(a, b)
  tree[a].add(b)
  for j in range(i):
    if a in tree[j]:
      # print(j)
      tree[j].add(b)
      
for i in range(Q):
  p, x = map(int, input().split())
  for node in tree[p]:
    points[node-1] += x

# print(tree)

for point in points:
  print(point, end=" ")

Fixed submission:
n,q = map(int,input().split())
rl = [0] * n
scores = [0] * n
for i in range(n-1):
    a,b = map(int,input().split())
    rl[b-1] = a-1
for j in range(q):
    p,x = map(int,input().split())
    scores[p-1] += x
for k in range(1,n):
    scores[k] += scores[rl[k]]
print(*scores)