def main():

    from collections import defaultdict

    from collections import deque

    import sys

    input = sys.stdin.readline

    dd = defaultdict(list)

    pq = defaultdict(int)



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



    for _ in range(N-1):

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

        dd[a].append(b)



    for _ in range(Q):

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

        pq[p] += q

    

    answer = [0]*N

    queue = deque()

    queue.append(1)



    while queue != deque():

        tmp = queue.popleft()

        answer[tmp-1] += pq[tmp]

        for i in dd[tmp]:

            queue.append(i)

            answer[i-1] += answer[tmp-1]

            

    print((*answer))



if __name__ == '__main__':

    main()
def main():

    from collections import defaultdict

    from collections import deque

    import sys

    input = sys.stdin.readline

    dd = defaultdict(list)

    pq = defaultdict(int)



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



    for _ in range(N-1):

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

        dd[a].append(b)

        dd[b].append(a)



    for _ in range(Q):

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

        pq[p] += q

    

    answer = [0]*N

    queue = deque()

    visited = {}

    visited[1] = 1

    queue.append(1)



    while queue != deque():

        tmp = queue.popleft()

        answer[tmp-1] += pq[tmp]

        for i in dd[tmp]:

            if not i in visited:

                visited[i] = 1

                queue.append(i)

                answer[i-1] += answer[tmp-1]

            

    print((*answer))



if __name__ == '__main__':

    main()
def main():
    from collections import defaultdict
    from collections import deque
    import sys

    input = sys.stdin.readline
    dd = defaultdict(list)
    pq = defaultdict(int)
    N, Q = list(map(int, input().split()))
    for _ in range(N - 1):
        a, b = list(map(int, input().split()))
        dd[a].append(b)
    for _ in range(Q):
        p, q = list(map(int, input().split()))
        pq[p] += q
    answer = [0] * N
    queue = deque()
    queue.append(1)
    while queue != deque():
        tmp = queue.popleft()
        answer[tmp - 1] += pq[tmp]
        for i in dd[tmp]:
            queue.append(i)
            answer[i - 1] += answer[tmp - 1]
    print((*answer))


if __name__ == "__main__":
    main()

def main():
    from collections import defaultdict
    from collections import deque
    import sys

    input = sys.stdin.readline
    dd = defaultdict(list)
    pq = defaultdict(int)
    N, Q = list(map(int, input().split()))
    for _ in range(N - 1):
        a, b = list(map(int, input().split()))
        dd[a].append(b)
        dd[b].append(a)
    for _ in range(Q):
        p, q = list(map(int, input().split()))
        pq[p] += q
    answer = [0] * N
    queue = deque()
    visited = {}
    visited[1] = 1
    queue.append(1)
    while queue != deque():
        tmp = queue.popleft()
        answer[tmp - 1] += pq[tmp]
        for i in dd[tmp]:
            if not i in visited:
                visited[i] = 1
                queue.append(i)
                answer[i - 1] += answer[tmp - 1]
    print((*answer))


if __name__ == "__main__":
    main()

+        dd[b].append(a) +    visited = {} +    visited[1] = 1 -            queue.append(i) -            answer[i - 1] += answer[tmp - 1] +            if not i in visited: +                visited[i] = 1 +                queue.append(i) +                answer[i - 1] += answer[tmp - 1]