Buggy python submission (verdict: Time Limit Exceeded):
import sys 
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())
G = [[] for _ in range(n)]
point = [0]*n
for _ in range(n-1):
    a,b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
for i in range(q):
    p, x = map(int, input().split())
    p = p-1
    point[p] += x

def dfs(now, prev = -1):
    for next in G[now]:
        if next == prev:
            continue
        point[next] += point[now]
        dfs(next, now)

dfs(0)
print(*point)    
 


Fixed submission:
import sys 
sys.setrecursionlimit(10**6)
import sys
def input():
    return sys.stdin.readline()[:-1]
n, q = map(int, input().split())
G = [[] for _ in range(n)]
point = [0]*n
for _ in range(n-1):
    a,b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
for i in range(q):
    p, x = map(int, input().split())
    p = p-1
    point[p] += x

def dfs(now, prev = -1):
    for next in G[now]:
        if next == prev:
            continue
        point[next] += point[now]
        dfs(next, now)

dfs(0)
print(*point)

Buggy python submission (verdict: Time Limit Exceeded):
import sys 
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())
G = [[] for _ in range(n)]
point = [0]*n
for _ in range(n-1):
    a,b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
for i in range(q):
    p, x = map(int, input().split())
    p = p-1
    point[p] += x

def dfs(now, prev = -1):
    for next in G[now]:
        if next == prev:
            continue
        point[next] += point[now]
        dfs(next, now)

dfs(0)
print(*point)    
 


Fixed submission:
import sys 
sys.setrecursionlimit(10**6)
import sys
def input():
    return sys.stdin.readline()[:-1]
n, q = map(int, input().split())
G = [[] for _ in range(n)]
point = [0]*n
for _ in range(n-1):
    a,b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
for i in range(q):
    p, x = map(int, input().split())
    p = p-1
    point[p] += x

def dfs(now, prev = -1):
    for next in G[now]:
        if next == prev:
            continue
        point[next] += point[now]
        dfs(next, now)

dfs(0)
print(*point)

Buggy python submission (verdict: Time Limit Exceeded):
import sys 
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())
G = [[] for _ in range(n)]
point = [0]*n
for _ in range(n-1):
    a,b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
for i in range(q):
    p, x = map(int, input().split())
    p = p-1
    point[p] += x

def dfs(now, prev = -1):
    for next in G[now]:
        if next == prev:
            continue
        point[next] += point[now]
        dfs(next, now)

dfs(0)
print(*point)    
 

Fixed submission:
import sys 
sys.setrecursionlimit(10**6)
import sys
def input():
    return sys.stdin.readline()[:-1]
n, q = map(int, input().split())
G = [[] for _ in range(n)]
point = [0]*n
for _ in range(n-1):
    a,b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
for i in range(q):
    p, x = map(int, input().split())
    p = p-1
    point[p] += x

def dfs(now, prev = -1):
    for next in G[now]:
        if next == prev:
            continue
        point[next] += point[now]
        dfs(next, now)

dfs(0)
print(*point)