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

n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
point = [0]*n

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

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


def dfs(now, past):
    for nv in neighbor[now]:
        if nv == past:
            continue
        point[nv] += point[now]
        dfs(nv, now)


dfs(0, -1)


print(*point)


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
point = [0]*n

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

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


def dfs(now, past):
    for nv in neighbor[now]:
        if nv == past:
            continue
        point[nv] += point[now]
        dfs(nv, now)


dfs(0, -1)


print(*point)

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

n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
point = [0]*n

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

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


def dfs(now, past):
    for nv in neighbor[now]:
        if nv == past:
            continue
        point[nv] += point[now]
        dfs(nv, now)


dfs(0, -1)


print(*point)


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
point = [0]*n

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

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


def dfs(now, past):
    for nv in neighbor[now]:
        if nv == past:
            continue
        point[nv] += point[now]
        dfs(nv, now)


dfs(0, -1)


print(*point)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import sys
sys.setrecursionlimit(10**9)

n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
point = [0]*n

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

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


def dfs(now, past):
    for nv in neighbor[now]:
        if nv == past:
            continue
        point[nv] += point[now]
        dfs(nv, now)


dfs(0, -1)


print(*point)


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
point = [0]*n

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

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


def dfs(now, past):
    for nv in neighbor[now]:
        if nv == past:
            continue
        point[nv] += point[now]
        dfs(nv, now)


dfs(0, -1)


print(*point)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
pl = []

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

for i in range(q):
    pl.append(list(map(int, input().split())))

parent = [-1 for _ in range(n)]
child = [[] for _ in range(n)]
parent[0] = 0
point = [0] * n
que = deque([])


def makeTree():
    global parent, neighbor, child, que
    queue = deque([[0, 0]])
    while len(queue) > 0:
        now = queue.popleft()
        que.append(now[0])
        for neiv in neighbor[now[0]]:
            if parent[neiv] == -1:
                parent[neiv] = now[0]
                queue.append([neiv, now[1]])
                child[now[0]].append(neiv)


def calcPoint():
    global pl, parent, point, que
    for p in pl:
        point[p[0] - 1] += p[1]
    que.popleft()
    for v in que:
        point[v] += point[parent[v]]


makeTree()

calcPoint()

print(*point)


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
point = [0]*n

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

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


def dfs(now, past):
    for nv in neighbor[now]:
        if nv == past:
            continue
        point[nv] += point[now]
        dfs(nv, now)


dfs(0, -1)


print(*point)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
pl = []

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

for i in range(q):
    pl.append(list(map(int, input().split())))

parent = [-1 for _ in range(n)]
child = [[] for _ in range(n)]
parent[0] = 0
point = [0] * n
que = deque([])


def makeTree():
    global parent, neighbor, child
    queue = deque([[0, 0]])
    while len(queue) > 0:
        now = queue.popleft()
        que.append(now[0])
        for neiv in neighbor[now[0]]:
            if parent[neiv] == -1:
                parent[neiv] = now[0]
                queue.append([neiv, now[1]])
                child[now[0]].append(neiv)


def calcPoint():
    global pl, parent, point, que
    for p in pl:
        point[p[0] - 1] += p[1]
    que.popleft()
    while len(que) > 0:
        now = que.popleft()
        point[now] += point[parent[now]]


makeTree()

calcPoint()

print(*point)


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
point = [0]*n

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

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


def dfs(now, past):
    for nv in neighbor[now]:
        if nv == past:
            continue
        point[nv] += point[now]
        dfs(nv, now)


dfs(0, -1)


print(*point)

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
pl = []

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

for i in range(q):
    pl.append(list(map(int, input().split())))

parent = [-1 for _ in range(n)]
child = [[] for _ in range(n)]
parent[0] = 0
point = [0] * n
que = []


def makeTree():
    global parent, neighbor, child
    queue = [[0, 0]]
    while len(queue) > 0:
        now = queue.pop(0)
        que.append(now[0])
        for neiv in neighbor[now[0]]:
            if parent[neiv] == -1:
                parent[neiv] = now[0]
                queue.append([neiv, now[1]])
                child[now[0]].append(neiv)


def calcPoint():
    global pl, parent, point, que
    for p in pl:
        point[p[0] - 1] += p[1]
    que.pop(0)
    while len(que) > 0:
        now = que.pop(0)
        point[now] += point[parent[now]]


makeTree()

calcPoint()

print(*point)


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
point = [0]*n

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

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


def dfs(now, past):
    for nv in neighbor[now]:
        if nv == past:
            continue
        point[nv] += point[now]
        dfs(nv, now)


dfs(0, -1)


print(*point)

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
pl = []

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

for i in range(q):
    pl.append(list(map(int, input().split())))

parent = [-1 for _ in range(n)]
child = [[] for _ in range(n)]
parent[0] = 0
point = [0] * n


def makeTree():
    global parent, neighbor, child
    queue = [[0, 0]]
    while len(queue) > 0:
        now = queue.pop(0)

        for neiv in neighbor[now[0]]:
            if parent[neiv] == -1:
                parent[neiv] = now[0]
                queue.append([neiv, now[1]])
                child[now[0]].append(neiv)


def calcPoint():
    global pl, parent, point
    for p in pl:
        point[p[0] - 1] += p[1]

    queue = child[0]
    while len(queue) > 0:
        now = queue.pop(0)
        point[now] += point[parent[now]]
        queue.extend(child[now])


makeTree()

calcPoint()

print(*point)


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
point = [0]*n

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

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


def dfs(now, past):
    for nv in neighbor[now]:
        if nv == past:
            continue
        point[nv] += point[now]
        dfs(nv, now)


dfs(0, -1)


print(*point)

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
pl = []

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

for i in range(q):
    pl.append(list(map(int, input().split())))

parent = [-1 for _ in range(n)]
child = [[] for _ in range(n)]
parent[0] = 0
point = [0] * n


def makeTree():
    global parent, neighbor, child
    queue = [[0, 0]]
    while len(queue) > 0:
        now = queue.pop(0)

        for neiv in neighbor[now[0]]:
            if parent[neiv] == -1:
                parent[neiv] = now[0]
                queue.append([neiv, now[1]])
                child[now[0]].append(neiv)


def calcPoint():
    global pl, parent, point
    for p in pl:
        point[p[0] - 1] += p[1]

    queue = child[0]
    while len(queue) > 0:
        now = queue.pop(0)
        point[now] += point[parent[now]]
        queue.extend(child[now])


makeTree()

calcPoint()

print(*point)


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
point = [0]*n

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

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


def dfs(now, past):
    for nv in neighbor[now]:
        if nv == past:
            continue
        point[nv] += point[now]
        dfs(nv, now)


dfs(0, -1)


print(*point)