def solve():

    import sys

    sys.setrecursionlimit(10**9)

    input = sys.stdin.readline



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

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

    for _ in range(N-1):

        A, B = list(map(int, input().split()))

        A, B = A-1, B-1

        adjL[A].append(B)

        adjL[B].append(A)



    anss = [0] * N

    for _ in range(Q):

        p, x = list(map(int, input().split()))

        p = p-1

        anss[p] += x



    def dfs(vNow, vPar, x):

        anss[vNow] += x

        ans = anss[vNow]

        for v2 in adjL[vNow]:

            if v2 != vPar:

                dfs(v2, vNow, ans)



    dfs(0, -1, 0)



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



solve()

from collections import deque

import sys

input = sys.stdin.readline



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

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

for _ in range(N-1):

    a, b = list(map(int, input().split()))

    a, b = a-1, b-1

    adjL[a].append(b)

    adjL[b].append(a)

querys = [tuple(map(int, input().split())) for _ in range(Q)]



anss = [0] * N

for p, x in querys:

    anss[p-1] += x



def bfs(vSt):

    useds = [False] * (N)

    useds[vSt] = True

    Q = deque([vSt])

    while Q:

        vNow = Q.popleft()

        ans = anss[vNow]

        for v2 in adjL[vNow]:

            if not useds[v2]:

                anss[v2] += ans

                Q.append(v2)

                useds[v2] = True



bfs(0)



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

def solve():
    import sys

    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline
    N, Q = list(map(int, input().split()))
    adjL = [[] for _ in range(N)]
    for _ in range(N - 1):
        A, B = list(map(int, input().split()))
        A, B = A - 1, B - 1
        adjL[A].append(B)
        adjL[B].append(A)
    anss = [0] * N
    for _ in range(Q):
        p, x = list(map(int, input().split()))
        p = p - 1
        anss[p] += x

    def dfs(vNow, vPar, x):
        anss[vNow] += x
        ans = anss[vNow]
        for v2 in adjL[vNow]:
            if v2 != vPar:
                dfs(v2, vNow, ans)

    dfs(0, -1, 0)
    print((" ".join(map(str, anss))))


solve()

from collections import deque
import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
adjL = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    a, b = a - 1, b - 1
    adjL[a].append(b)
    adjL[b].append(a)
querys = [tuple(map(int, input().split())) for _ in range(Q)]
anss = [0] * N
for p, x in querys:
    anss[p - 1] += x


def bfs(vSt):
    useds = [False] * (N)
    useds[vSt] = True
    Q = deque([vSt])
    while Q:
        vNow = Q.popleft()
        ans = anss[vNow]
        for v2 in adjL[vNow]:
            if not useds[v2]:
                anss[v2] += ans
                Q.append(v2)
                useds[v2] = True


bfs(0)
print((" ".join(map(str, anss))))

-def solve(): -    import sys +from collections import deque +import sys -    sys.setrecursionlimit(10**9) -    input = sys.stdin.readline -    N, Q = list(map(int, input().split())) -    adjL = [[] for _ in range(N)] -    for _ in range(N - 1): -        A, B = list(map(int, input().split())) -        A, B = A - 1, B - 1 -        adjL[A].append(B) -        adjL[B].append(A) -    anss = [0] * N -    for _ in range(Q): -        p, x = list(map(int, input().split())) -        p = p - 1 -        anss[p] += x +input = sys.stdin.readline +N, Q = list(map(int, input().split())) +adjL = [[] for _ in range(N)] +for _ in range(N - 1): +    a, b = list(map(int, input().split())) +    a, b = a - 1, b - 1 +    adjL[a].append(b) +    adjL[b].append(a) +querys = [tuple(map(int, input().split())) for _ in range(Q)] +anss = [0] * N +for p, x in querys: +    anss[p - 1] += x -    def dfs(vNow, vPar, x): -        anss[vNow] += x + +def bfs(vSt): +    useds = [False] * (N) +    useds[vSt] = True +    Q = deque([vSt]) +    while Q: +        vNow = Q.popleft() -            if v2 != vPar: -                dfs(v2, vNow, ans) - -    dfs(0, -1, 0) -    print((" ".join(map(str, anss)))) +            if not useds[v2]: +                anss[v2] += ans +                Q.append(v2) +                useds[v2] = True -solve() +bfs(0) +print((" ".join(map(str, anss))))