from collections import deque



def bfs(N, d, ans):

    Q = deque([0])

    visited = [False] * N

    visited[0] = True

    while Q:

        q = Q.popleft()



        for p in d[q]:

            if visited[p]:

                continue

            visited[p] = True

            Q.append(p)

            ans[p] += ans[q]



    return ans





def main():

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

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



    for i in range(N-1):

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

        a -= 1

        b -= 1

        d[a].append(b)

        d[b].append(a)



    ans = [0] * N

    for _ in range(Q):

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

        p -= 1

        ans[p] += x



    print((*bfs(N, d, ans)))

    



main()
import sys

from collections import deque

input = sys.stdin.readline



def main():

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

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

    for _ in range(N-1):

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

        a -= 1

        b -= 1

        edge[a].append(b)

        edge[b].append(a)

        

    ans = [0] * N

    for _ in range(Q):

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

        p -= 1 

        ans[p] += x

    visited = [False] * N

    Q = deque()

    Q.append(0)

    while Q:

        v = Q.popleft()

        visited[v] = True

        for d in edge[v]:

            if visited[d]:

                continue

            Q.append(d)

            ans[d] += ans[v]



    print((*ans))







if __name__ == "__main__":

    main()
from collections import deque


def bfs(N, d, ans):
    Q = deque([0])
    visited = [False] * N
    visited[0] = True
    while Q:
        q = Q.popleft()
        for p in d[q]:
            if visited[p]:
                continue
            visited[p] = True
            Q.append(p)
            ans[p] += ans[q]
    return ans


def main():
    N, Q = list(map(int, input().split()))
    d = [[] for _ in range(N)]
    for i in range(N - 1):
        a, b = list(map(int, input().split()))
        a -= 1
        b -= 1
        d[a].append(b)
        d[b].append(a)
    ans = [0] * N
    for _ in range(Q):
        p, x = list(map(int, input().split()))
        p -= 1
        ans[p] += x
    print((*bfs(N, d, ans)))


main()

import sys
from collections import deque

input = sys.stdin.readline


def main():
    N, Q = list(map(int, input().split()))
    edge = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = list(map(int, input().split()))
        a -= 1
        b -= 1
        edge[a].append(b)
        edge[b].append(a)
    ans = [0] * N
    for _ in range(Q):
        p, x = list(map(int, input().split()))
        p -= 1
        ans[p] += x
    visited = [False] * N
    Q = deque()
    Q.append(0)
    while Q:
        v = Q.popleft()
        visited[v] = True
        for d in edge[v]:
            if visited[d]:
                continue
            Q.append(d)
            ans[d] += ans[v]
    print((*ans))


if __name__ == "__main__":
    main()

+import sys - -def bfs(N, d, ans): -    Q = deque([0]) -    visited = [False] * N -    visited[0] = True -    while Q: -        q = Q.popleft() -        for p in d[q]: -            if visited[p]: -                continue -            visited[p] = True -            Q.append(p) -            ans[p] += ans[q] -    return ans +input = sys.stdin.readline -    d = [[] for _ in range(N)] -    for i in range(N - 1): +    edge = [[] for _ in range(N)] +    for _ in range(N - 1): -        d[a].append(b) -        d[b].append(a) +        edge[a].append(b) +        edge[b].append(a) -    print((*bfs(N, d, ans))) +    visited = [False] * N +    Q = deque() +    Q.append(0) +    while Q: +        v = Q.popleft() +        visited[v] = True +        for d in edge[v]: +            if visited[d]: +                continue +            Q.append(d) +            ans[d] += ans[v] +    print((*ans)) -main() +if __name__ == "__main__": +    main()