def solve():

    import sys

    sys.setrecursionlimit(10**6)

    def dfs(tree, n, ans):

        for i in tree[n]:

            ans[i] += ans[n]

            tree[i].remove(n)

            dfs(tree, i, ans) #再帰関数になっている。次の木の中を探索

     

    n, q = list(map(int,input().split()))

    ab = [list(map(int,input().split())) for _ in range(n-1)]

    px = [list(map(int,input().split())) for _ in range(q)]

     

    g = [[] for _ in range(n)]

    for i in range(n-1):

        g[ab[i][0]-1].append(ab[i][1]-1)

        g[ab[i][1]-1].append(ab[i][0]-1)

    

    ans = [0]*n

    for i in range(q):

        ans[px[i-1][0]-1] += px[i-1][1]

    dfs(g, 0, ans)

     

    print((*ans))

    

if __name__ == "__main__":

    solve()
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

 

n,q = list(map(int,readline().split()))

ABPX = list(map(int,read().split()))

AB = iter(ABPX[:n+n-2])

PX = iter(ABPX[n+n-2:])



graph = [[] for _ in range(n+1)]

for a, b in zip(AB, AB):

    graph[a].append(b)

    graph[b].append(a)



val = [0] * (n+1)

for p, x in zip(PX, PX):

    val[p] += x



stack = [1] #queue的なやつ

parent = [0] * (n+1)

while stack:

    x = stack.pop() #根を引っこ抜く

    for y in graph[x]: #木を見る

        if y == parent[x]:

            continue

        parent[y] = x

        stack.append(y)

        val[y] += val[x]

        

print((' '.join(map(str, val[1:]))))
def solve():
    import sys

    sys.setrecursionlimit(10**6)

    def dfs(tree, n, ans):
        for i in tree[n]:
            ans[i] += ans[n]
            tree[i].remove(n)
            dfs(tree, i, ans)  # 再帰関数になっている。次の木の中を探索

    n, q = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for _ in range(n - 1)]
    px = [list(map(int, input().split())) for _ in range(q)]
    g = [[] for _ in range(n)]
    for i in range(n - 1):
        g[ab[i][0] - 1].append(ab[i][1] - 1)
        g[ab[i][1] - 1].append(ab[i][0] - 1)
    ans = [0] * n
    for i in range(q):
        ans[px[i - 1][0] - 1] += px[i - 1][1]
    dfs(g, 0, ans)
    print((*ans))


if __name__ == "__main__":
    solve()

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, q = list(map(int, readline().split()))
ABPX = list(map(int, read().split()))
AB = iter(ABPX[: n + n - 2])
PX = iter(ABPX[n + n - 2 :])
graph = [[] for _ in range(n + 1)]
for a, b in zip(AB, AB):
    graph[a].append(b)
    graph[b].append(a)
val = [0] * (n + 1)
for p, x in zip(PX, PX):
    val[p] += x
stack = [1]  # queue的なやつ
parent = [0] * (n + 1)
while stack:
    x = stack.pop()  # 根を引っこ抜く
    for y in graph[x]:  # 木を見る
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)
        val[y] += val[x]
print((" ".join(map(str, val[1:]))))

-def solve(): -    import sys +import sys -    sys.setrecursionlimit(10**6) - -    def dfs(tree, n, ans): -        for i in tree[n]: -            ans[i] += ans[n] -            tree[i].remove(n) -            dfs(tree, i, ans)  # 再帰関数になっている。次の木の中を探索 - -    n, q = list(map(int, input().split())) -    ab = [list(map(int, input().split())) for _ in range(n - 1)] -    px = [list(map(int, input().split())) for _ in range(q)] -    g = [[] for _ in range(n)] -    for i in range(n - 1): -        g[ab[i][0] - 1].append(ab[i][1] - 1) -        g[ab[i][1] - 1].append(ab[i][0] - 1) -    ans = [0] * n -    for i in range(q): -        ans[px[i - 1][0] - 1] += px[i - 1][1] -    dfs(g, 0, ans) -    print((*ans)) - - -if __name__ == "__main__": -    solve() +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +n, q = list(map(int, readline().split())) +ABPX = list(map(int, read().split())) +AB = iter(ABPX[: n + n - 2]) +PX = iter(ABPX[n + n - 2 :]) +graph = [[] for _ in range(n + 1)] +for a, b in zip(AB, AB): +    graph[a].append(b) +    graph[b].append(a) +val = [0] * (n + 1) +for p, x in zip(PX, PX): +    val[p] += x +stack = [1]  # queue的なやつ +parent = [0] * (n + 1) +while stack: +    x = stack.pop()  # 根を引っこ抜く +    for y in graph[x]:  # 木を見る +        if y == parent[x]: +            continue +        parent[y] = x +        stack.append(y) +        val[y] += val[x] +print((" ".join(map(str, val[1:]))))