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

EDGES = [list(map(int, input().split())) for i in range(N-1)]

OPES = [list(map(int, input().split())) for i in range(Q)]

VALUES = [0 for i in range(N)]

#operation1

for o in OPES:

    VALUES[o[0]-1] += o[1]

#operation2

EDGES.sort(key=lambda e:e[0])

for e in EDGES:

    VALUES[e[1]-1] += VALUES[e[0]-1]

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

import sys

def main():

    input = sys.stdin.readline

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

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

    for _ in range(N-1):

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

        a,b=a-1,b-1

        G[a].append(b)

        G[b].append(a)

    C=[0]*N

    for _ in range(Q):

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

        C[p-1]+=x

    stk=[0]

    used=[False]*N

    used[0]=True

    while stk:

        v = stk.pop()

        for to in G[v]:

            if used[to]: continue

            used[to] = True

            C[to]+=C[v]

            stk.append(to)

    print((*C))





if __name__ == '__main__':

    main()
N, Q = list(map(int, input().split()))
EDGES = [list(map(int, input().split())) for i in range(N - 1)]
OPES = [list(map(int, input().split())) for i in range(Q)]
VALUES = [0 for i in range(N)]
# operation1
for o in OPES:
    VALUES[o[0] - 1] += o[1]
# operation2
EDGES.sort(key=lambda e: e[0])
for e in EDGES:
    VALUES[e[1] - 1] += VALUES[e[0] - 1]
print((" ".join(map(str, VALUES))))

import sys


def main():
    input = sys.stdin.readline
    N, Q = list(map(int, input().split()))
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = list(map(int, input().split()))
        a, b = a - 1, b - 1
        G[a].append(b)
        G[b].append(a)
    C = [0] * N
    for _ in range(Q):
        p, x = list(map(int, input().split()))
        C[p - 1] += x
    stk = [0]
    used = [False] * N
    used[0] = True
    while stk:
        v = stk.pop()
        for to in G[v]:
            if used[to]:
                continue
            used[to] = True
            C[to] += C[v]
            stk.append(to)
    print((*C))


if __name__ == "__main__":
    main()

-N, Q = list(map(int, input().split())) -EDGES = [list(map(int, input().split())) for i in range(N - 1)] -OPES = [list(map(int, input().split())) for i in range(Q)] -VALUES = [0 for i in range(N)] -# operation1 -for o in OPES: -    VALUES[o[0] - 1] += o[1] -# operation2 -EDGES.sort(key=lambda e: e[0]) -for e in EDGES: -    VALUES[e[1] - 1] += VALUES[e[0] - 1] -print((" ".join(map(str, VALUES)))) +import sys + + +def main(): +    input = sys.stdin.readline +    N, Q = list(map(int, input().split())) +    G = [[] for _ in range(N)] +    for _ in range(N - 1): +        a, b = list(map(int, input().split())) +        a, b = a - 1, b - 1 +        G[a].append(b) +        G[b].append(a) +    C = [0] * N +    for _ in range(Q): +        p, x = list(map(int, input().split())) +        C[p - 1] += x +    stk = [0] +    used = [False] * N +    used[0] = True +    while stk: +        v = stk.pop() +        for to in G[v]: +            if used[to]: +                continue +            used[to] = True +            C[to] += C[v] +            stk.append(to) +    print((*C)) + + +if __name__ == "__main__": +    main()