import sys

input=sys.stdin.readline



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



edge = [[] for _ in range(N+1)]

for _ in range(N-1):

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

    edge[a].append(b)

    edge[b].append(a)



P = []

for i in range(Q):

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

    P.append((x,y))



V = [0]*N

for p in P:

    V[p[0]-1] += p[1]



parent = {1}

done = {1}

while parent:

    children = set()

    for p in parent:

        for i in edge[p]:

            if i not in done:

                V[i-1] += V[p-1]

                children.add(i)

                done.add(i)

    parent = children



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

import sys

input=sys.stdin.readline



def main():

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



    edge = [[] for _ in range(N+1)]

    for _ in range(N-1):

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

        edge[a].append(b)

        edge[b].append(a)



    P = []

    for i in range(Q):

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

        P.append((x,y))



    V = [0]*N

    for p in P:

        V[p[0]-1] += p[1]



    parent = {1}

    done = {1}

    while parent:

        children = set()

        for p in parent:

            for i in edge[p]:

                if i not in done:

                    V[i-1] += V[p-1]

                    children.add(i)

                    done.add(i)

        parent = children



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



if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    edge[a].append(b)
    edge[b].append(a)
P = []
for i in range(Q):
    x, y = list(map(int, input().split()))
    P.append((x, y))
V = [0] * N
for p in P:
    V[p[0] - 1] += p[1]
parent = {1}
done = {1}
while parent:
    children = set()
    for p in parent:
        for i in edge[p]:
            if i not in done:
                V[i - 1] += V[p - 1]
                children.add(i)
                done.add(i)
    parent = children
print((" ".join(map(str, V))))

import sys

input = sys.stdin.readline


def main():
    N, Q = list(map(int, input().split()))
    edge = [[] for _ in range(N + 1)]
    for _ in range(N - 1):
        a, b = list(map(int, input().split()))
        edge[a].append(b)
        edge[b].append(a)
    P = []
    for i in range(Q):
        x, y = list(map(int, input().split()))
        P.append((x, y))
    V = [0] * N
    for p in P:
        V[p[0] - 1] += p[1]
    parent = {1}
    done = {1}
    while parent:
        children = set()
        for p in parent:
            for i in edge[p]:
                if i not in done:
                    V[i - 1] += V[p - 1]
                    children.add(i)
                    done.add(i)
        parent = children
    print((" ".join(map(str, V))))


if __name__ == "__main__":
    main()

-N, Q = list(map(int, input().split())) -edge = [[] for _ in range(N + 1)] -for _ in range(N - 1): -    a, b = list(map(int, input().split())) -    edge[a].append(b) -    edge[b].append(a) -P = [] -for i in range(Q): -    x, y = list(map(int, input().split())) -    P.append((x, y)) -V = [0] * N -for p in P: -    V[p[0] - 1] += p[1] -parent = {1} -done = {1} -while parent: -    children = set() -    for p in parent: -        for i in edge[p]: -            if i not in done: -                V[i - 1] += V[p - 1] -                children.add(i) -                done.add(i) -    parent = children -print((" ".join(map(str, V)))) + + +def main(): +    N, Q = list(map(int, input().split())) +    edge = [[] for _ in range(N + 1)] +    for _ in range(N - 1): +        a, b = list(map(int, input().split())) +        edge[a].append(b) +        edge[b].append(a) +    P = [] +    for i in range(Q): +        x, y = list(map(int, input().split())) +        P.append((x, y)) +    V = [0] * N +    for p in P: +        V[p[0] - 1] += p[1] +    parent = {1} +    done = {1} +    while parent: +        children = set() +        for p in parent: +            for i in edge[p]: +                if i not in done: +                    V[i - 1] += V[p - 1] +                    children.add(i) +                    done.add(i) +        parent = children +    print((" ".join(map(str, V)))) + + +if __name__ == "__main__": +    main()