import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



def abc138_d():

    N, _ = map(int, readline().strip().split())

    input_data = [tuple(map(int, ln.strip().split())) for ln in readlines()]



    # 隣接リスト作成

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

    for a, b in input_data[:N-1]:

        graph[a].append(b)

        graph[b].append(a)



    # クエリをもとにスコア加算　※頂点pだけに加算し、子へは加算しない

    val = [0] * (N+1)

    for p, x in input_data[N-1:]:

        val[p] += x



    # DFSで根元から順に足していく

    stack = [1]

    visited = [False] * (N+1)

    visited[1] = True

    while stack:

        x = stack.pop()

        for y in graph[x]:

            if visited[y]: continue

            stack.append(y)

            visited[y] = True

            val[y] += val[x]



    print(*val[1:], sep=' ')



abc138_d()

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



def abc138_d():

    N, _ = map(int, readline().strip().split())

    input_data = list(map(int, read().split()))

    AB = iter(input_data[:N+N-2])

    PX = iter(input_data[N+N-2:])



    # 隣接リスト作成

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

    for a, b in zip(AB, AB):

        graph[a].append(b)

        graph[b].append(a)



    # クエリをもとにスコア加算　※頂点pだけに加算し、子へは加算しない

    val = [0] * (N+1)

    for p, x in zip(PX, PX):

        val[p] += x



    # DFSで根元から順に足していく

    stack = [1]

    visited = [False] * (N+1)

    visited[1] = True

    while stack:

        x = stack.pop()

        for y in graph[x]:

            if visited[y]: continue

            stack.append(y)

            visited[y] = True

            val[y] += val[x]



    print(*val[1:], sep=' ')



abc138_d()

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def abc138_d():
    N, _ = map(int, readline().strip().split())
    input_data = [tuple(map(int, ln.strip().split())) for ln in readlines()]
    # 隣接リスト作成
    graph = [[] for _ in range(N + 1)]
    for a, b in input_data[: N - 1]:
        graph[a].append(b)
        graph[b].append(a)
    # クエリをもとにスコア加算　※頂点pだけに加算し、子へは加算しない
    val = [0] * (N + 1)
    for p, x in input_data[N - 1 :]:
        val[p] += x
    # DFSで根元から順に足していく
    stack = [1]
    visited = [False] * (N + 1)
    visited[1] = True
    while stack:
        x = stack.pop()
        for y in graph[x]:
            if visited[y]:
                continue
            stack.append(y)
            visited[y] = True
            val[y] += val[x]
    print(*val[1:], sep=" ")


abc138_d()

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def abc138_d():
    N, _ = map(int, readline().strip().split())
    input_data = list(map(int, read().split()))
    AB = iter(input_data[: N + N - 2])
    PX = iter(input_data[N + N - 2 :])
    # 隣接リスト作成
    graph = [[] for _ in range(N + 1)]
    for a, b in zip(AB, AB):
        graph[a].append(b)
        graph[b].append(a)
    # クエリをもとにスコア加算　※頂点pだけに加算し、子へは加算しない
    val = [0] * (N + 1)
    for p, x in zip(PX, PX):
        val[p] += x
    # DFSで根元から順に足していく
    stack = [1]
    visited = [False] * (N + 1)
    visited[1] = True
    while stack:
        x = stack.pop()
        for y in graph[x]:
            if visited[y]:
                continue
            stack.append(y)
            visited[y] = True
            val[y] += val[x]
    print(*val[1:], sep=" ")


abc138_d()

-    input_data = [tuple(map(int, ln.strip().split())) for ln in readlines()] +    input_data = list(map(int, read().split())) +    AB = iter(input_data[: N + N - 2]) +    PX = iter(input_data[N + N - 2 :]) -    for a, b in input_data[: N - 1]: +    for a, b in zip(AB, AB): -    for p, x in input_data[N - 1 :]: +    for p, x in zip(PX, PX):