Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin,setrecursionlimit
setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = [[] for _ in range(2 * (10 ** 5))]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)

d = [0] * N

for _ in range(Q):
    p, x = map(int, input().split())
    d[p - 1] += x

def dfs(u, v):
    global d
    for p in T[u]:
        if p == v:
            continue
        d[p] += d[u]
        dfs(p, u)

dfs(0, -1)

for v in d:
    print(v)


Fixed submission:
from sys import stdin,setrecursionlimit
input = stdin.readline
setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = [[] for _ in range(2 * (10 ** 5))]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)

d = [0] * N

for _ in range(Q):
    p, x = map(int, input().split())
    d[p - 1] += x

def dfs(u, v):
    global d
    for p in T[u]:
        if p == v:
            continue
        d[p] += d[u]
        dfs(p, u)

dfs(0, -1)

for v in d:
    print(v)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin,setrecursionlimit
setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = [[] for _ in range(2 * (10 ** 5))]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)

d = [0] * N

for _ in range(Q):
    p, x = map(int, input().split())
    d[p - 1] += x

def dfs(u, v = -1):
    global d
    for p in T[u]:
        if p == v:
            continue
        d[p] += d[u]
        dfs(p, u)

dfs(0)

for v in d:
    print(v)


Fixed submission:
from sys import stdin,setrecursionlimit
input = stdin.readline
setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = [[] for _ in range(2 * (10 ** 5))]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)

d = [0] * N

for _ in range(Q):
    p, x = map(int, input().split())
    d[p - 1] += x

def dfs(u, v):
    global d
    for p in T[u]:
        if p == v:
            continue
        d[p] += d[u]
        dfs(p, u)

dfs(0, -1)

for v in d:
    print(v)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = [[] for i in range(2 * (10 ** 5))]
for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)

d = [0] * N

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

def dfs(u, v = -1):
    global d
    for p in T[u]:
        if p != v:
            d[p] += d[u]
            dfs(p, u)

dfs(0)

for v in d:
    print(v)


Fixed submission:
from sys import stdin,setrecursionlimit
input = stdin.readline
setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = [[] for _ in range(2 * (10 ** 5))]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)

d = [0] * N

for _ in range(Q):
    p, x = map(int, input().split())
    d[p - 1] += x

def dfs(u, v):
    global d
    for p in T[u]:
        if p == v:
            continue
        d[p] += d[u]
        dfs(p, u)

dfs(0, -1)

for v in d:
    print(v)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = [[] for i in range(2 * (10 ** 5))]
for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)

d = [0] * N

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

def dfs(u, v = -1):
    global d
    for p in T[u]:
        if p != v:
            d[p] += d[u]
            dfs(p, u)

dfs(0)


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


Fixed submission:
from sys import stdin,setrecursionlimit
input = stdin.readline
setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = [[] for _ in range(2 * (10 ** 5))]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)

d = [0] * N

for _ in range(Q):
    p, x = map(int, input().split())
    d[p - 1] += x

def dfs(u, v):
    global d
    for p in T[u]:
        if p == v:
            continue
        d[p] += d[u]
        dfs(p, u)

dfs(0, -1)

for v in d:
    print(v)

Buggy python submission (verdict: Time Limit Exceeded):

import sys
sys.setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = {}
for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a in T:
        T[a].append(b)
    else:
        T[a] = [b]
    if b in T:
        T[b].append(a)
    else:
        T[b] = [a]

d = [0] * N

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

def dfs(u, v = -1):
    global d
    if u in T:
        for p in T[u]:
            if p != v:
                d[p] += d[u]
                dfs(p, u)

dfs(0)


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



Fixed submission:
from sys import stdin,setrecursionlimit
input = stdin.readline
setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = [[] for _ in range(2 * (10 ** 5))]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)

d = [0] * N

for _ in range(Q):
    p, x = map(int, input().split())
    d[p - 1] += x

def dfs(u, v):
    global d
    for p in T[u]:
        if p == v:
            continue
        d[p] += d[u]
        dfs(p, u)

dfs(0, -1)

for v in d:
    print(v)

Buggy python submission (verdict: Runtime Error):

N, Q = map(int, input().split())
T = {}
for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a in T:
        T[a].append(b)
    else:
        T[a] = [b]
    if b in T:
        T[b].append(a)
    else:
        T[b] = [a]

d = [0] * N

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

def dfs(u, v = -1):
    global d
    if u in T:
        for p in T[u]:
            if p != v:
                d[p] += d[u]
                dfs(p, u)

dfs(0)


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



Fixed submission:
from sys import stdin,setrecursionlimit
input = stdin.readline
setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = [[] for _ in range(2 * (10 ** 5))]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)

d = [0] * N

for _ in range(Q):
    p, x = map(int, input().split())
    d[p - 1] += x

def dfs(u, v):
    global d
    for p in T[u]:
        if p == v:
            continue
        d[p] += d[u]
        dfs(p, u)

dfs(0, -1)

for v in d:
    print(v)

Buggy python submission (verdict: Runtime Error):

N, Q = map(int, input().split())
T = {}
for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a in T:
        T[a].append(b)
    else:
        T[a] = [b]
    if b in T:
        T[b].append(a)
    else:
        T[b] = [a]

d = [0] * N

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

def dfs(u, v = -1):
    if u in T:
        for p in T[u]:
            if p != v:
                d[p] += d[u]
                dfs(p, u)

dfs(0)


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


Fixed submission:
from sys import stdin,setrecursionlimit
input = stdin.readline
setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = [[] for _ in range(2 * (10 ** 5))]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)

d = [0] * N

for _ in range(Q):
    p, x = map(int, input().split())
    d[p - 1] += x

def dfs(u, v):
    global d
    for p in T[u]:
        if p == v:
            continue
        d[p] += d[u]
        dfs(p, u)

dfs(0, -1)

for v in d:
    print(v)

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
A = []
B = []

for i in range(N - 1):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

P = []
X = []
for i in range(Q):
    p, x = map(int, input().split())
    P.append(p)
    X.append(x)


T = {}
for i in range(len(A)):
    a = A[i]
    b = B[i]
    if a in T:
        T[a].append(b)
    else:
        T[a] = [b]

def subnode(n, l):
    l.append(n)
    if n in T:
        for n2 in T[n]:
            l = subnode(n2, l)
    return l

T2 = {}
for i in range(1, N + 1):
    T2[i] = subnode(i, [])

d = [0] * N

for i in range(len(P)):
    p = P[i]
    x = X[i]
    l = T2[p]
    for i in l:
        d[i - 1] += x


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


Fixed submission:
from sys import stdin,setrecursionlimit
input = stdin.readline
setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = [[] for _ in range(2 * (10 ** 5))]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)

d = [0] * N

for _ in range(Q):
    p, x = map(int, input().split())
    d[p - 1] += x

def dfs(u, v):
    global d
    for p in T[u]:
        if p == v:
            continue
        d[p] += d[u]
        dfs(p, u)

dfs(0, -1)

for v in d:
    print(v)

Buggy python submission (verdict: Runtime Error):

N, Q = map(int, input().split())
A = []
B = []

for i in range(N - 1):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

P = []
X = []
for i in range(Q):
    p, x = map(int, input().split())
    P.append(p)
    X.append(x)

T = {}
for i in range(len(A)):
    a = A[i]
    b = B[i]
    if a in T:
        T[a].append(b)
    else:
        T[a] = [b]

d = [0] * N

def inctree(p, x):
    d[p - 1] += x
    if p in T:
        l = T[p]
        for p2 in l:
            inctree(p2, x)

for i in range(len(P)):
    p = P[i]

    x = X[i]
    inctree(p, x)


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


Fixed submission:
from sys import stdin,setrecursionlimit
input = stdin.readline
setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = [[] for _ in range(2 * (10 ** 5))]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)

d = [0] * N

for _ in range(Q):
    p, x = map(int, input().split())
    d[p - 1] += x

def dfs(u, v):
    global d
    for p in T[u]:
        if p == v:
            continue
        d[p] += d[u]
        dfs(p, u)

dfs(0, -1)

for v in d:
    print(v)