Buggy python submission (verdict: Time Limit Exceeded):
n, q = list(map(int, input().split(" ")))
a = []
b = []
tree = []

class Node:
    def __init__(self, id):
        self.id = id
        self.counter = 0
        self.linked = []

    def add_node(self, node):
        self.linked.append(node)

    def add_count(self, count):
        self.counter += count

# make node
for i in range(n):
    tree.append(Node(i))
# add node
for i in range(n-1):
    j, k = list(map(int, input().split(" ")))
    tree[j-1].add_node(tree[k-1])

# add count
for i in range(q):
    j, k = list(map(int, input().split(" ")))
    tree[j-1].add_count(k)

# traverse
for i in tree:
    for j in i.linked:
        j.counter += i.counter

m = []
for i in tree:
    m.append(i.counter)

print(" ".join(map(str, m)))


Fixed submission:
n, q = list(map(int, input().split(" ")))
a = []
b = []
tree = []

class Node:
    def __init__(self, id):
        self.id = id
        self.counter = 0
        self.linked = []

    def add_node(self, node):
        self.linked.append(node)

    def add_count(self, count):
        self.counter += count

# make node
for i in range(n):
    tree.append(Node(i))

# add node
for i in range(n-1):
    j, k = list(map(int, input().split(" ")))
    tree[j-1].add_node(tree[k-1])

# add count
for i in range(q):
    j, k = list(map(int, input().split(" ")))
    tree[j-1].add_count(k)

# traverse
for i in tree:
    for j in i.linked:
        j.counter += i.counter

m = []
for i in tree:
    m.append(i.counter)

print(" ".join(map(str, m)))

Buggy python submission (verdict: Time Limit Exceeded):
# 4 3
# 1 2
# 2 3
# 2 4
# 2 10
# 1 100
# 3 1

n, q = list(map(int, input().split(" ")))
a = []
b = []
for i in range(n-1):
    j, k = list(map(int, input().split(" ")))
    a.append(j)
    b.append(k)

p = []
x = []
for i in range(q):
    j, k = list(map(int, input().split(" ")))
    p.append(j)
    x.append(k)


class Node:
    def __init__(self, id):
        self.id = id
        self.counter = 0
        self.linked = []

    def add_node(self, node):
        self.linked.append(node)

    def add_count(self, count):
        self.counter += count


# make node
tree = []
for i in range(n):
    tree.append(Node(i))

for j, k in zip(a, b):
    tree[j-1].add_node(tree[k-1])

for j, k in zip(p, x):
    tree[j-1].add_count(k)

# traverse
for i in tree:
    for j in i.linked:
        j.counter += i.counter

m = []
for i in tree:
    m.append(i.counter)

print(" ".join(map(str, m)))






Fixed submission:
n, q = list(map(int, input().split(" ")))
a = []
b = []
tree = []

class Node:
    def __init__(self, id):
        self.id = id
        self.counter = 0
        self.linked = []

    def add_node(self, node):
        self.linked.append(node)

    def add_count(self, count):
        self.counter += count

# make node
for i in range(n):
    tree.append(Node(i))

# add node
for i in range(n-1):
    j, k = list(map(int, input().split(" ")))
    tree[j-1].add_node(tree[k-1])

# add count
for i in range(q):
    j, k = list(map(int, input().split(" ")))
    tree[j-1].add_count(k)

# traverse
for i in tree:
    for j in i.linked:
        j.counter += i.counter

m = []
for i in tree:
    m.append(i.counter)

print(" ".join(map(str, m)))

Buggy python submission (verdict: Runtime Error):
# 4 3
# 1 2
# 2 3
# 2 4
# 2 10
# 1 100
# 3 1

n, q = list(map(int, input().split(" ")))
a = []
b = []
for i in range(n-1):
    j, k = list(map(int, input().split(" ")))
    a.append(j)
    b.append(k)

p = []
x = []
for i in range(q):
    j, k = list(map(int, input().split(" ")))
    p.append(j)
    x.append(k)


class Node:
    def __init__(self, id):
        self.id = id
        self.counter = 0
        self.linked = []

    def add_node(self, node):
        self.linked.append(node)

    def add_count(self, count):
        self.counter += count
        for i in self.linked:
            i.add_count(count)

# make node
tree = []
for i in range(n):
    tree.append(Node(i))

for j, k in zip(a, b):
    tree[j-1].add_node(tree[k-1])

for j, k in zip(p, x):
    tree[j-1].add_count(k)

m = []
for i in tree:
    m.append(i.counter)

print(" ".join(map(str, m)))



Fixed submission:
n, q = list(map(int, input().split(" ")))
a = []
b = []
tree = []

class Node:
    def __init__(self, id):
        self.id = id
        self.counter = 0
        self.linked = []

    def add_node(self, node):
        self.linked.append(node)

    def add_count(self, count):
        self.counter += count

# make node
for i in range(n):
    tree.append(Node(i))

# add node
for i in range(n-1):
    j, k = list(map(int, input().split(" ")))
    tree[j-1].add_node(tree[k-1])

# add count
for i in range(q):
    j, k = list(map(int, input().split(" ")))
    tree[j-1].add_count(k)

# traverse
for i in tree:
    for j in i.linked:
        j.counter += i.counter

m = []
for i in tree:
    m.append(i.counter)

print(" ".join(map(str, m)))