from collections import deque





def solve():

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

    ab = [[0, 0] for _ in range(N-1)]

    for i in range(N-1):

        ab[i] = list(map(int, input().split()))

    px = [[0, 0] for _ in range(Q)]

    for i in range(Q):

        px[i] = list(map(int, input().split()))



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

    for a, b in ab:

        graph[a].append(b)

        graph[b].append(a)



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

    for p, x in px:

        val[p] += x



    que = deque([1])

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

    while que:

        i = que.popleft()

        for j in graph[i]:

            if j == parent[i]:

                continue

            parent[j] = i

            que.append(j)

            val[j] += val[i]



    print((*val[1:]))





if __name__ == '__main__':

    solve()
from collections import deque





def solve():

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

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

    for i in range(N-1):

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

        graph[a].append(b)

        graph[b].append(a)

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

    for i in range(Q):

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

        val[p] += x



    que = deque([1])

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

    while que:

        i = que.popleft()

        for j in graph[i]:

            if j == parent[i]:

                continue

            parent[j] = i

            que.append(j)

            val[j] += val[i]



    print((*val[1:]))





if __name__ == '__main__':

    solve()
from collections import deque


def solve():
    N, Q = list(map(int, input().split()))
    ab = [[0, 0] for _ in range(N - 1)]
    for i in range(N - 1):
        ab[i] = list(map(int, input().split()))
    px = [[0, 0] for _ in range(Q)]
    for i in range(Q):
        px[i] = list(map(int, input().split()))
    graph = [[] for _ in range(N + 1)]
    for a, b in ab:
        graph[a].append(b)
        graph[b].append(a)
    val = [0 for _ in range(N + 1)]
    for p, x in px:
        val[p] += x
    que = deque([1])
    parent = [0 for _ in range(N + 1)]
    while que:
        i = que.popleft()
        for j in graph[i]:
            if j == parent[i]:
                continue
            parent[j] = i
            que.append(j)
            val[j] += val[i]
    print((*val[1:]))


if __name__ == "__main__":
    solve()

from collections import deque


def solve():
    N, Q = list(map(int, input().split()))
    graph = [[] for _ in range(N + 1)]
    for i in range(N - 1):
        a, b = list(map(int, input().split()))
        graph[a].append(b)
        graph[b].append(a)
    val = [0 for _ in range(N + 1)]
    for i in range(Q):
        p, x = list(map(int, input().split()))
        val[p] += x
    que = deque([1])
    parent = [0 for _ in range(N + 1)]
    while que:
        i = que.popleft()
        for j in graph[i]:
            if j == parent[i]:
                continue
            parent[j] = i
            que.append(j)
            val[j] += val[i]
    print((*val[1:]))


if __name__ == "__main__":
    solve()

-    ab = [[0, 0] for _ in range(N - 1)] +    graph = [[] for _ in range(N + 1)] -        ab[i] = list(map(int, input().split())) -    px = [[0, 0] for _ in range(Q)] -    for i in range(Q): -        px[i] = list(map(int, input().split())) -    graph = [[] for _ in range(N + 1)] -    for a, b in ab: +        a, b = list(map(int, input().split())) -    for p, x in px: +    for i in range(Q): +        p, x = list(map(int, input().split()))