Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)
n,q=[int(_) for _ in input().split()]
ki=[[] for _ in range(n)]
ans=[0]*n

def dfs(numQ,parent):
    for child in ki[numQ]:
        if child==parent:
            continue
        ans[child]+=ans[numQ]
        dfs(child,numQ)

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

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

dfs(0,-1)
print(*ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n,q=map(int,input().split())
ki=[[] for _ in range(n)]
ans=[0]*n

def dfs(numQ,parent):
    for child in ki[numQ]:
        if child==parent:
            continue
        ans[child]+=ans[numQ]
        dfs(child,numQ)

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

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

dfs(0,-1)
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n,q=map(int,input().split())
ki=[[] for _ in range(n)]
ans=[0]*n

def dfs(numQ,parent):
    for child in ki[numQ]:
        if child==parent:
            continue
        ans[child]+=ans[numQ]
        dfs(child,numQ)

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

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

dfs(0,-1)
print(*ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n,q=map(int,input().split())
ki=[[] for _ in range(n)]
ans=[0]*n

def dfs(numQ,parent):
    for child in ki[numQ]:
        if child==parent:
            continue
        ans[child]+=ans[numQ]
        dfs(child,numQ)

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

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

dfs(0,-1)
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n,q=map(int,input().split())
ki=[[] for _ in range(n)]
ans=[0]*n

def dfs(numQ,parent):
    for child in ki[numQ]:
        if child==parent:
            continue
        ans[child]+=ans[numQ]
        dfs(child,numQ)

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

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

dfs(0,-1)
print(*ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n,q=map(int,input().split())
ki=[[] for _ in range(n)]
ans=[0]*n

def dfs(numQ,parent):
    for child in ki[numQ]:
        if child==parent:
            continue
        ans[child]+=ans[numQ]
        dfs(child,numQ)

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

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

dfs(0,-1)
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n,q=map(int,input().split())
ki=[[] for _ in range(n)]
ans=[0]*n

def dfs(numQ,parent):
    for child in ki[numQ]:
        if child!=parent:
            ans[child]+=ans[numQ]
            dfs(child,numQ)

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

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

dfs(0,-1)
print(*ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n,q=map(int,input().split())
ki=[[] for _ in range(n)]
ans=[0]*n

def dfs(numQ,parent):
    for child in ki[numQ]:
        if child==parent:
            continue
        ans[child]+=ans[numQ]
        dfs(child,numQ)

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

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

dfs(0,-1)
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
sys.setrecursionlimit(10**6)
n,q=map(int,input().split())
ki=[[] for _ in range(n)]
ans=[0]*n

def dfs(numQ,parent):
    for child in ki[numQ]:
        if child!=parent:
            ans[child]+=ans[numQ]
            dfs(child,numQ)

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

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

dfs(0,-1)
print(*ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n,q=map(int,input().split())
ki=[[] for _ in range(n)]
ans=[0]*n

def dfs(numQ,parent):
    for child in ki[numQ]:
        if child==parent:
            continue
        ans[child]+=ans[numQ]
        dfs(child,numQ)

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

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

dfs(0,-1)
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
sys.setrecursionlimit(10**6)
n,q=[int(i) for i in input().split()]
ki=[[] for _ in range(n)]
ans=[0]*n

def dfs(numQ,parent):
    for child in ki[numQ]:
        if child!=parent:
            ans[child]+=ans[numQ]
            dfs(child,numQ)

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

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

dfs(0,-1)
print(*ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n,q=map(int,input().split())
ki=[[] for _ in range(n)]
ans=[0]*n

def dfs(numQ,parent):
    for child in ki[numQ]:
        if child==parent:
            continue
        ans[child]+=ans[numQ]
        dfs(child,numQ)

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

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

dfs(0,-1)
print(*ans)