Buggy python submission (verdict: Time Limit Exceeded):
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    
    N,Q=MI()
    edges = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = MI_()
        edges[a].append(b)
        edges[b].append(a)
    counter = [0]*N
    for _ in range(Q):
        p,x = MI()
        counter[p-1]+=x

    serched = {0}
    def dfs(now_sum,node):
        now_sum += counter[node]

        ans[node] = now_sum
        for b in edges[node]:
            if b not in serched:
                serched.add(b)
                dfs(now_sum,b)
            

    ans = [0]*N
    dfs(0,0)
    print(*ans)


    
if __name__ == '__main__':
    main()

Fixed submission:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    
    N,Q=MI()
    edges = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = MI_()
        edges[a].append(b)
        edges[b].append(a)
    counter = [0]*N
    for _ in range(Q):
        p,x = MI()
        counter[p-1]+=x

    serched = {0}
    def dfs(now_sum,node):
        now_sum += counter[node]

        ans[node] = now_sum
        for b in edges[node]:
            if b not in serched:
                serched.add(b)
                dfs(now_sum,b)
            

    ans = [0]*N
    dfs(0,0)
    print(*ans)


    
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    
    N,Q=MI()
    edges = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = MI_()
        edges[a].append(b)
        edges[b].append(a)
    counter = [0]*N
    for _ in range(Q):
        p,x = MI()
        counter[p-1]+=x

    serched = {0}
    def dfs(now_sum,node):
        now_sum += counter[node]

        ans[node] = now_sum
        for b in edges[node]:
            if b not in serched:
                serched.add(b)
                dfs(now_sum,b)
            

    ans = [0]*N
    dfs(0,0)
    print(*ans)


    
if __name__ == '__main__':
    main()

Fixed submission:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    
    N,Q=MI()
    edges = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = MI_()
        edges[a].append(b)
        edges[b].append(a)
    counter = [0]*N
    for _ in range(Q):
        p,x = MI()
        counter[p-1]+=x

    serched = {0}
    def dfs(now_sum,node):
        now_sum += counter[node]

        ans[node] = now_sum
        for b in edges[node]:
            if b not in serched:
                serched.add(b)
                dfs(now_sum,b)
            

    ans = [0]*N
    dfs(0,0)
    print(*ans)


    
if __name__ == '__main__':
    main()