Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
child=[[] for _ in range(n)]
point=[0 for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    child[a-1].append(b-1)

for i in range(q):
    p,x=map(int,input().split())
    point[p-1]+=x

ans=[0 for _ in range(n)]
def dfs(vertex,pt):
    pt_v=pt+point[vertex]
    ans[vertex]=pt_v
    child_v=child[vertex]
    for i in range(len(child_v)):
        dfs(child_v[i],pt_v)


dfs(0,0)

for i in range(n):
    print(ans[i],end=" ")


Fixed submission:
from collections import deque
import sys
sys.setrecursionlimit(10**9)

n,q=map(int,input().split())

link=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)

v_counter=[0 for _ in range(n)]
for _ in range(q):
    p,x=map(int,input().split())
    v_counter[p-1]+=x

point=[0 for _ in range(n)]
que=deque()
que.append(0)
used=set()
used.add(0)
point[0] += v_counter[0]

while(len(que)>0):
    ind=que.popleft()
    relate=link[ind]
    for i in relate:
        if(i in used):
            continue
        else:
            point[i] += point[ind] + v_counter[i]
            que.append(i)
            used.add(i)

print(*point)

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
child=[[] for _ in range(n)]
point=[0 for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    child[a-1].append(b-1)

for i in range(q):
    p,x=map(int,input().split())
    point[p-1]+=x

ans=[0 for _ in range(n)]
def dfs(vertex,pt):
    pt_v=pt+point[vertex]
    ans[vertex]=pt_v
    child_v=child[vertex]
    for i in range(len(child_v)):
        dfs(child_v[i],pt_v)


dfs(0,0)

for i in range(n):
    print(ans[i],end=" ")


Fixed submission:
from collections import deque
import sys
sys.setrecursionlimit(10**9)

n,q=map(int,input().split())

link=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)

v_counter=[0 for _ in range(n)]
for _ in range(q):
    p,x=map(int,input().split())
    v_counter[p-1]+=x

point=[0 for _ in range(n)]
que=deque()
que.append(0)
used=set()
used.add(0)
point[0] += v_counter[0]

while(len(que)>0):
    ind=que.popleft()
    relate=link[ind]
    for i in relate:
        if(i in used):
            continue
        else:
            point[i] += point[ind] + v_counter[i]
            que.append(i)
            used.add(i)

print(*point)

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
child=[[] for _ in range(n+1)]
point=[0 for _ in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    child[a].append(b)

for i in range(q):
    p,x=map(int,input().split())
    point[p]+=x

ans=[0 for _ in range(n+1)]
def dfs(vertex,pt):
    pt_v=pt+point[vertex]
    ans[vertex]=pt_v
    child_v=child[vertex]
    for i in range(len(child_v)):
        dfs(child_v[i],pt_v)


dfs(1,0)

for i in range(1,n+1):
    print(ans[i],end=" ")


Fixed submission:
from collections import deque
import sys
sys.setrecursionlimit(10**9)

n,q=map(int,input().split())

link=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)

v_counter=[0 for _ in range(n)]
for _ in range(q):
    p,x=map(int,input().split())
    v_counter[p-1]+=x

point=[0 for _ in range(n)]
que=deque()
que.append(0)
used=set()
used.add(0)
point[0] += v_counter[0]

while(len(que)>0):
    ind=que.popleft()
    relate=link[ind]
    for i in relate:
        if(i in used):
            continue
        else:
            point[i] += point[ind] + v_counter[i]
            que.append(i)
            used.add(i)

print(*point)

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
v_counter=[0 for _ in range(n+1)]
v_parent=[0 for _ in range(n+1)]

v_depth=[0 for _ in range(n+1)]
v_depth[1]=1
depth=[[] for _ in range(n+1)]
depth[1].append(1)

for i in range(n-1):
    a,b=map(int,input().split())
    v_parent[b]=a
    v_depth[b]=v_depth[a]+1
    depth[v_depth[b]].append(b)

for i in range(q):
    p,x=map(int,input().split())
    v_counter[p]+=x

v_list=[]
i=1
while(len(depth[i])!=0):
    v_list.extend(depth[i])
    i+=1

for i in range(n):
    vi=v_list[i]
    v_counter[vi]+=v_counter[v_parent[vi]]

for i in range(1,n+1):
    print(v_counter[i],end=" ")
print()


Fixed submission:
from collections import deque
import sys
sys.setrecursionlimit(10**9)

n,q=map(int,input().split())

link=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)

v_counter=[0 for _ in range(n)]
for _ in range(q):
    p,x=map(int,input().split())
    v_counter[p-1]+=x

point=[0 for _ in range(n)]
que=deque()
que.append(0)
used=set()
used.add(0)
point[0] += v_counter[0]

while(len(que)>0):
    ind=que.popleft()
    relate=link[ind]
    for i in relate:
        if(i in used):
            continue
        else:
            point[i] += point[ind] + v_counter[i]
            que.append(i)
            used.add(i)

print(*point)