# ABC138D - Ki

from collections import deque





def main():

    # Ai (A[i][0]) may be not a parent of Bi (A[i][1])

    global T, cnt

    N, Q, *A = list(map(int, open(0).read().split()))

    E, P = A[: (N - 1) * 2], A[(N - 1) * 2 :]

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

    for v, u in zip(*[iter(E)] * 2):

        T[v].append(u), T[u].append(v)

    cnt = [0] * (N + 1)

    for p, x in zip(*[iter(P)] * 2):

        cnt[p] += x  # increase vertex p by x

    stack = deque([(1, -1)])

    while stack:

        v, p = stack.popleft()

        x = cnt[v]

        for u in T[v]:

            if u != p:

                cnt[u] += x

                stack.append((u, v))

    print((*cnt[1:]))





if __name__ == "__main__":

    main()
# ABC138D - Ki

from collections import deque





def main():

    N, Q, *X = list(map(int, open(0).read().split()))

    AB, PX = X[: 2 * (N - 1)], X[2 * (N - 1) :]



    tree, cnt = [[] for _ in range(N + 1)], [0] * (N + 1)

    for a, b in zip(*[iter(AB)] * 2):

        tree[a].append(b), tree[b].append(a)

    for p, x in zip(*[iter(PX)] * 2):

        cnt[p] += x



    queue = deque([1])

    is_searched = [False] * (N + 1)

    is_searched[1] = True

    while queue:

        u = queue.popleft()

        cur_cnt = cnt[u]

        is_searched[u] = True

        for v in tree[u]:

            if is_searched[v]:

                continue

            cnt[v] += cur_cnt

            queue.append(v)



    print((" ".join(map(str, cnt[1:]))))





if __name__ == "__main__":

    main()

# ABC138D - Ki
from collections import deque


def main():
    # Ai (A[i][0]) may be not a parent of Bi (A[i][1])
    global T, cnt
    N, Q, *A = list(map(int, open(0).read().split()))
    E, P = A[: (N - 1) * 2], A[(N - 1) * 2 :]
    T = [[] for _ in range(N + 1)]
    for v, u in zip(*[iter(E)] * 2):
        T[v].append(u), T[u].append(v)
    cnt = [0] * (N + 1)
    for p, x in zip(*[iter(P)] * 2):
        cnt[p] += x  # increase vertex p by x
    stack = deque([(1, -1)])
    while stack:
        v, p = stack.popleft()
        x = cnt[v]
        for u in T[v]:
            if u != p:
                cnt[u] += x
                stack.append((u, v))
    print((*cnt[1:]))


if __name__ == "__main__":
    main()

# ABC138D - Ki
from collections import deque


def main():
    N, Q, *X = list(map(int, open(0).read().split()))
    AB, PX = X[: 2 * (N - 1)], X[2 * (N - 1) :]
    tree, cnt = [[] for _ in range(N + 1)], [0] * (N + 1)
    for a, b in zip(*[iter(AB)] * 2):
        tree[a].append(b), tree[b].append(a)
    for p, x in zip(*[iter(PX)] * 2):
        cnt[p] += x
    queue = deque([1])
    is_searched = [False] * (N + 1)
    is_searched[1] = True
    while queue:
        u = queue.popleft()
        cur_cnt = cnt[u]
        is_searched[u] = True
        for v in tree[u]:
            if is_searched[v]:
                continue
            cnt[v] += cur_cnt
            queue.append(v)
    print((" ".join(map(str, cnt[1:]))))


if __name__ == "__main__":
    main()

-    # Ai (A[i][0]) may be not a parent of Bi (A[i][1]) -    global T, cnt -    N, Q, *A = list(map(int, open(0).read().split())) -    E, P = A[: (N - 1) * 2], A[(N - 1) * 2 :] -    T = [[] for _ in range(N + 1)] -    for v, u in zip(*[iter(E)] * 2): -        T[v].append(u), T[u].append(v) -    cnt = [0] * (N + 1) -    for p, x in zip(*[iter(P)] * 2): -        cnt[p] += x  # increase vertex p by x -    stack = deque([(1, -1)]) -    while stack: -        v, p = stack.popleft() -        x = cnt[v] -        for u in T[v]: -            if u != p: -                cnt[u] += x -                stack.append((u, v)) -    print((*cnt[1:])) +    N, Q, *X = list(map(int, open(0).read().split())) +    AB, PX = X[: 2 * (N - 1)], X[2 * (N - 1) :] +    tree, cnt = [[] for _ in range(N + 1)], [0] * (N + 1) +    for a, b in zip(*[iter(AB)] * 2): +        tree[a].append(b), tree[b].append(a) +    for p, x in zip(*[iter(PX)] * 2): +        cnt[p] += x +    queue = deque([1]) +    is_searched = [False] * (N + 1) +    is_searched[1] = True +    while queue: +        u = queue.popleft() +        cur_cnt = cnt[u] +        is_searched[u] = True +        for v in tree[u]: +            if is_searched[v]: +                continue +            cnt[v] += cur_cnt +            queue.append(v) +    print((" ".join(map(str, cnt[1:]))))