# ABC138D - Ki

import sys



input = sys.stdin.readline

sys.setrecursionlimit(10 ** 9)





def dfs(v: int, p: int) -> None:

    x = cnt[v]

    for u in T[v]:

        if u != p:  # p: parent -> skip

            cnt[u] += x  # cumulative sum

            dfs(u, v)





def main():

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

    global T, cnt

    N, Q = tuple(map(int, input().rstrip().split()))  # vertices and queues

    E = tuple(tuple(map(int, input().rstrip().split())) for _ in range(N - 1))

    P = tuple(tuple(map(int, input().rstrip().split())) for _ in range(Q))

    T = [[] for _ in range(N + 1)]  # tree, N+1: 1-idx

    for a, b in E:

        T[a] += [b]

        T[b] += [a]

    cnt = [0] * (N + 1)

    for p, x in P:

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

    dfs(1, -1)

    print((*cnt[1:]))





if __name__ == "__main__":

    main()
# ABC138D - Ki

import sys



input = sys.stdin.readline

sys.setrecursionlimit(10 ** 6)





def dfs(v: int, p: int) -> None:

    x = cnt[v]

    for u in T[v]:

        if u != p:

            cnt[u] += x  # cumulative sum

            dfs(u, v)





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

    dfs(1, -1)

    print((*cnt[1:]))





if __name__ == "__main__":

    main()
# ABC138D - Ki
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**9)


def dfs(v: int, p: int) -> None:
    x = cnt[v]
    for u in T[v]:
        if u != p:  # p: parent -> skip
            cnt[u] += x  # cumulative sum
            dfs(u, v)


def main():
    # Ai (A[i][0]) may be not a parent of Bi (A[i][1])
    global T, cnt
    N, Q = tuple(map(int, input().rstrip().split()))  # vertices and queues
    E = tuple(tuple(map(int, input().rstrip().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().rstrip().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]  # tree, N+1: 1-idx
    for a, b in E:
        T[a] += [b]
        T[b] += [a]
    cnt = [0] * (N + 1)
    for p, x in P:
        cnt[p] += x  # increase vertex p by x
    dfs(1, -1)
    print((*cnt[1:]))


if __name__ == "__main__":
    main()

# ABC138D - Ki
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def dfs(v: int, p: int) -> None:
    x = cnt[v]
    for u in T[v]:
        if u != p:
            cnt[u] += x  # cumulative sum
            dfs(u, v)


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
    dfs(1, -1)
    print((*cnt[1:]))


if __name__ == "__main__":
    main()

-sys.setrecursionlimit(10**9) +sys.setrecursionlimit(10**6) -        if u != p:  # p: parent -> skip +        if u != p: -    N, Q = tuple(map(int, input().rstrip().split()))  # vertices and queues -    E = tuple(tuple(map(int, input().rstrip().split())) for _ in range(N - 1)) -    P = tuple(tuple(map(int, input().rstrip().split())) for _ in range(Q)) -    T = [[] for _ in range(N + 1)]  # tree, N+1: 1-idx -    for a, b in E: -        T[a] += [b] -        T[b] += [a] +    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) -    for p, x in P: +    for p, x in zip(*[iter(P)] * 2):