# 深さ優先探索の問題

import sys



sys.setrecursionlimit(10**6)

readline = sys.stdin.readline



N, Q = list(map(int, input().split()))



# 隣接リスト

t = [[] for _ in range(N)]

for _ in range(N-1):

    a, b = [int(i) for i in readline().split()]

    t[a-1].append(b-1)

    t[b-1].append(a-1)



# スコア

s = [0] * N

for _ in range(Q):

    p, x = [int(i) for i in readline().split()]

    #s[p-1] = s[p-1] + x

    s[p-1] += x



ans = [0] * N



# 深さ優先探索

def dfs(v, p, value):

    #value = value + s[v]

    value += s[v]

    ans[v] = value

    for c in t[v]:

        if c == p:

            continue

        dfs(c, v, value)



dfs(0, -1, 0)



print((*ans))

# 深さ優先探索の問題

import sys



sys.setrecursionlimit(10**6)

readline = sys.stdin.readline



N, Q = list(map(int, input().split()))



# 隣接リスト

t = [[] for _ in range(N)]

for _ in range(N-1):

    a, b = [int(i) for i in readline().split()]

    t[a-1].append(b-1)

    t[b-1].append(a-1)



# スコア

score = [0] * N

for _ in range(Q):

    p, x = [int(i) for i in readline().split()]

    #s[p-1] = s[p-1] + x

    score[p-1] += x



ans = [0] * N



# 深さ優先探索 (スタック)

rootchecker = [0] * N

rootchecker[0] = 1

stack = [0]

while stack:

    #print(stack)

    s = stack.pop()

    ans[s] += score[s]

    for c in t[s]:

        if rootchecker[c] == 0:

            ans[c] += ans[s]

            rootchecker[c] = 1

            stack.append(c)



print((*ans))

# 深さ優先探索の問題
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
N, Q = list(map(int, input().split()))
# 隣接リスト
t = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = [int(i) for i in readline().split()]
    t[a - 1].append(b - 1)
    t[b - 1].append(a - 1)
# スコア
s = [0] * N
for _ in range(Q):
    p, x = [int(i) for i in readline().split()]
    # s[p-1] = s[p-1] + x
    s[p - 1] += x
ans = [0] * N
# 深さ優先探索
def dfs(v, p, value):
    # value = value + s[v]
    value += s[v]
    ans[v] = value
    for c in t[v]:
        if c == p:
            continue
        dfs(c, v, value)


dfs(0, -1, 0)
print((*ans))

# 深さ優先探索の問題
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
N, Q = list(map(int, input().split()))
# 隣接リスト
t = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = [int(i) for i in readline().split()]
    t[a - 1].append(b - 1)
    t[b - 1].append(a - 1)
# スコア
score = [0] * N
for _ in range(Q):
    p, x = [int(i) for i in readline().split()]
    # s[p-1] = s[p-1] + x
    score[p - 1] += x
ans = [0] * N
# 深さ優先探索 (スタック)
rootchecker = [0] * N
rootchecker[0] = 1
stack = [0]
while stack:
    # print(stack)
    s = stack.pop()
    ans[s] += score[s]
    for c in t[s]:
        if rootchecker[c] == 0:
            ans[c] += ans[s]
            rootchecker[c] = 1
            stack.append(c)
print((*ans))

-s = [0] * N +score = [0] * N -    s[p - 1] += x +    score[p - 1] += x -# 深さ優先探索 -def dfs(v, p, value): -    # value = value + s[v] -    value += s[v] -    ans[v] = value -    for c in t[v]: -        if c == p: -            continue -        dfs(c, v, value) - - -dfs(0, -1, 0) +# 深さ優先探索 (スタック) +rootchecker = [0] * N +rootchecker[0] = 1 +stack = [0] +while stack: +    # print(stack) +    s = stack.pop() +    ans[s] += score[s] +    for c in t[s]: +        if rootchecker[c] == 0: +            ans[c] += ans[s] +            rootchecker[c] = 1 +            stack.append(c)