Buggy python submission (verdict: Time Limit Exceeded):
import queue
n,q = map(int,input().split())
l = [0 for i in range(n)]
l2 = [[] for i in range(n)]
l3 = [0 for i in range(n)]
l3[0] = 1
for i in range(n-1):
    a,b = map(int,input().split())
    l2[b-1].append(a-1)
    l2[a-1].append(b-1)
for i in range(q):
    c,d = map(int,input().split())
    l[c-1] += d
ans = [0 for i in range(n)]
ans[0] = l[0]
q1 = queue.Queue()
q1.put(0)
while not q1.empty():
    k = q1.get()
    q2 = l2[k]
    for i in range(len(q2)):
        k1 = q2[i]
        if l3[k1] == 0:
            ans[k1] = ans[k] + l[k1]
            q1.put(k1)
            l3[k1] = 1
for x in ans:
    print(x,end=" ")

Fixed submission:
from collections import deque
n,q = map(int,input().split())
l = [0 for i in range(n)]
l2 = [[] for i in range(n)]
l3 = [0 for i in range(n)]
l3[0] = 1
for i in range(n-1):
    a,b = map(int,input().split())
    l2[b-1].append(a-1)
    l2[a-1].append(b-1)
for i in range(q):
    c,d = map(int,input().split())
    l[c-1] += d
ans = [0 for i in range(n)]
ans[0] = l[0]
q1 = deque()
q1.append((0,-1))
while len(q1) > 0:
    k,g = q1.popleft()
    for j in l2[k]:
        if j == g:
            continue
        ans[j] = ans[k] + l[j]
        q1.append((j,k))
for x in ans:
    print(x,end=" ")

Buggy python submission (verdict: Time Limit Exceeded):
import queue
n,q = map(int,input().split())
l = [0 for i in range(n)]
l2 = [queue.Queue() for i in range(n)]
l3 = [0 for i in range(n)]
l3[0] = 1
for i in range(n-1):
    a,b = map(int,input().split())
    l2[b-1].put(a-1)
    l2[a-1].put(b-1)
for i in range(q):
    c,d = map(int,input().split())
    l[c-1] += d
ans = [0 for i in range(n)]
ans[0] = l[0]
q1 = queue.Queue()
q1.put(0)
while not q1.empty():
    k = q1.get()
    q2 = l2[k]
    while not q2.empty():
        k1 = q2.get()
        if l3[k1] == 0:
            ans[k1] = ans[k] + l[k1]
            q1.put(k1)
            l3[k1] = 1
for x in ans:
    print(x,end=" ")

Fixed submission:
from collections import deque
n,q = map(int,input().split())
l = [0 for i in range(n)]
l2 = [[] for i in range(n)]
l3 = [0 for i in range(n)]
l3[0] = 1
for i in range(n-1):
    a,b = map(int,input().split())
    l2[b-1].append(a-1)
    l2[a-1].append(b-1)
for i in range(q):
    c,d = map(int,input().split())
    l[c-1] += d
ans = [0 for i in range(n)]
ans[0] = l[0]
q1 = deque()
q1.append((0,-1))
while len(q1) > 0:
    k,g = q1.popleft()
    for j in l2[k]:
        if j == g:
            continue
        ans[j] = ans[k] + l[j]
        q1.append((j,k))
for x in ans:
    print(x,end=" ")

Buggy python submission (verdict: Time Limit Exceeded):
import queue
n,q = map(int,input().split())
l = [0 for i in range(n)]
l2 = [queue.Queue() for i in range(n)]
l3 = [0 for i in range(n)]
l3[0] = 1
for i in range(n-1):
    a,b = map(int,input().split())
    l2[b-1].put(a-1)
    l2[a-1].put(b-1)
for i in range(q):
    c,d = map(int,input().split())
    l[c-1] += d
ans = [0 for i in range(n)]
ans[0] = l[0]
q1 = queue.Queue()
q1.put(0)
while not q1.empty():
    k = q1.get()
    q2 = l2[k]
    while not q2.empty():
        k1 = q2.get()
        if l3[k1] == 0:
            ans[k1] = ans[k] + l[k1]
            q1.put(k1)
            l3[k1] = 1
for x in ans:
    print(x,end=" ")

Fixed submission:
from collections import deque
n,q = map(int,input().split())
l = [0 for i in range(n)]
l2 = [[] for i in range(n)]
l3 = [0 for i in range(n)]
l3[0] = 1
for i in range(n-1):
    a,b = map(int,input().split())
    l2[b-1].append(a-1)
    l2[a-1].append(b-1)
for i in range(q):
    c,d = map(int,input().split())
    l[c-1] += d
ans = [0 for i in range(n)]
ans[0] = l[0]
q1 = deque()
q1.append((0,-1))
while len(q1) > 0:
    k,g = q1.popleft()
    for j in l2[k]:
        if j == g:
            continue
        ans[j] = ans[k] + l[j]
        q1.append((j,k))
for x in ans:
    print(x,end=" ")