Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,Q = map(int,input().split())
tree = {}
px = []
counter = [0 for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    if a in tree:
        tree[a].append(b)
    else:
        tree[a] = [b]
    if b in tree:
        tree[b].append(a)
    else:
        tree[b] = [a]
for _ in range(Q):
    ip,ix = map(int,input().split())
    px.append([ip,ix])


oya = deque([1])

while oya:
    oyai = oya.popleft()
    for ko in tree[oyai]:
        tree[ko].remove(oyai)
        oya.append(ko)


for pi,xi in px:
    oya = deque([pi])
    
    while oya:
        oyai = oya.popleft()
        counter[oyai-1] +=xi
        for ko in tree[oyai]:
            oya.append(ko)  
[print(i,end=" ") for i in counter]


Fixed submission:
# coding: utf-8
# Your code here!
from collections import deque
N,Q = map(int,input().split())
tree = {}
px = []
counter = [0 for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    if a in tree:
        tree[a].append(b)
    else:
        tree[a] = [b]
    if b in tree:
        tree[b].append(a)
    else:
        tree[b] = [a]
for _ in range(Q):
    ip,ix = map(int,input().split())
    counter[ip-1] += ix


oya = deque([1])

while oya:
    oyai = oya.popleft()
    for ko in tree[oyai]:
        tree[ko].remove(oyai)
        counter[ko-1] += counter[oyai-1]
        oya.append(ko)




print(' '.join(map(str,counter)))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
from collections import deque
N,Q = map(int,input().split())
tree = {}
px = []
counter = [0 for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    if a in tree:
        tree[a].append(b)
    else:
        tree[a] = [b]
    if b in tree:
        tree[b].append(a)
    else:
        tree[b] = [a]
for _ in range(Q):
    ip,ix = map(int,input().split())
    px.append([ip,ix])


oya = deque([1])

while oya:
    oyai = oya.popleft()
    for ko in tree[oyai]:
        tree[ko].remove(oyai)
        oya.append(ko)


for pi,xi in px:
    oya = deque([pi])
    
    while oya:
        oyai = oya.popleft()
        counter[oyai-1] +=xi
        for ko in tree[oyai]:
            oya.append(ko)  
print(' '.join(map(str,counter)))


Fixed submission:
# coding: utf-8
# Your code here!
from collections import deque
N,Q = map(int,input().split())
tree = {}
px = []
counter = [0 for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    if a in tree:
        tree[a].append(b)
    else:
        tree[a] = [b]
    if b in tree:
        tree[b].append(a)
    else:
        tree[b] = [a]
for _ in range(Q):
    ip,ix = map(int,input().split())
    counter[ip-1] += ix


oya = deque([1])

while oya:
    oyai = oya.popleft()
    for ko in tree[oyai]:
        tree[ko].remove(oyai)
        counter[ko-1] += counter[oyai-1]
        oya.append(ko)




print(' '.join(map(str,counter)))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
from collections import deque
N,Q = map(int,input().split())
tree = {}
px = []
counter = [0 for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    if a in tree:
        tree[a].append(b)
    else:
        tree[a] = [b]
    if b in tree:
        tree[b].append(a)
    else:
        tree[b] = [a]
for _ in range(Q):
    ip,ix = map(int,input().split())
    px.append([ip,ix])


oya = deque([1])

while oya:
    oyai = oya.popleft()
    for ko in tree[oyai]:
        tree[ko].remove(oyai)
        oya.append(ko)


for pi,xi in px:
    oya = deque([pi])
    
    while oya:
        oyai = oya.popleft()
        counter[oyai-1] +=xi
        for ko in tree[oyai]:
            oya.append(ko)  
print(' '.join(map(str,counter)))


Fixed submission:
# coding: utf-8
# Your code here!
from collections import deque
N,Q = map(int,input().split())
tree = {}
px = []
counter = [0 for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    if a in tree:
        tree[a].append(b)
    else:
        tree[a] = [b]
    if b in tree:
        tree[b].append(a)
    else:
        tree[b] = [a]
for _ in range(Q):
    ip,ix = map(int,input().split())
    counter[ip-1] += ix


oya = deque([1])

while oya:
    oyai = oya.popleft()
    for ko in tree[oyai]:
        tree[ko].remove(oyai)
        counter[ko-1] += counter[oyai-1]
        oya.append(ko)




print(' '.join(map(str,counter)))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
N,Q = map(int,input().split())
tree = {}
px = []
counter = [0 for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    if a in tree:
        tree[a] |= {b}
    else:
        tree[a] = {b}
    if b in tree:
        tree[b] |= {a}
    else:
        tree[b] = {a}
for _ in range(Q):
    ip,ix = map(int,input().split())
    px.append([ip,ix])


oya = [1]

while oya:
    oyai = oya.pop(0)
    for ko in tree[oyai]:
        tree[ko].remove(oyai)
        oya.append(ko)


for pi,xi in px:
    oya = [pi]
    
    while oya:
        oyai = oya.pop(0)
        counter[oyai-1] +=xi
        for ko in tree[oyai]:
            oya.append(ko)  
print(' '.join(map(str,counter)))


Fixed submission:
# coding: utf-8
# Your code here!
from collections import deque
N,Q = map(int,input().split())
tree = {}
px = []
counter = [0 for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    if a in tree:
        tree[a].append(b)
    else:
        tree[a] = [b]
    if b in tree:
        tree[b].append(a)
    else:
        tree[b] = [a]
for _ in range(Q):
    ip,ix = map(int,input().split())
    counter[ip-1] += ix


oya = deque([1])

while oya:
    oyai = oya.popleft()
    for ko in tree[oyai]:
        tree[ko].remove(oyai)
        counter[ko-1] += counter[oyai-1]
        oya.append(ko)




print(' '.join(map(str,counter)))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
N,Q = map(int,input().split())
tree = {}
px = []
counter = [0 for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    if a in tree:
        tree[a] |= {b}
    else:
        tree[a] = {b}
    if b in tree:
        tree[b] |= {a}
    else:
        tree[b] = {a}
for _ in range(Q):
    ip,ix = map(int,input().split())
    px.append([ip,ix])


oya = [1]

while oya:
    oyai = oya.pop(0)
    for ko in tree[oyai]:
        tree[ko].remove(oyai)
        oya.append(ko)


for pi,xi in px:
    oya = [pi]
    
    while oya:
        oyai = oya.pop(0)
        counter[oyai-1] +=xi
        for ko in tree[oyai]:
            oya.append(ko)  
print(' '.join(map(str,counter)))


Fixed submission:
# coding: utf-8
# Your code here!
from collections import deque
N,Q = map(int,input().split())
tree = {}
px = []
counter = [0 for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    if a in tree:
        tree[a].append(b)
    else:
        tree[a] = [b]
    if b in tree:
        tree[b].append(a)
    else:
        tree[b] = [a]
for _ in range(Q):
    ip,ix = map(int,input().split())
    counter[ip-1] += ix


oya = deque([1])

while oya:
    oyai = oya.popleft()
    for ko in tree[oyai]:
        tree[ko].remove(oyai)
        counter[ko-1] += counter[oyai-1]
        oya.append(ko)




print(' '.join(map(str,counter)))