import sys

from collections import deque



readline = sys.stdin.readline

sys.setrecursionlimit(10 ** 9)





def main():

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

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

    for _ in range(N - 1):

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

        G[a - 1].append(b - 1)

        G[b - 1].append(a - 1)

    X = [0] * N

    for i in range(Q):

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

        X[p - 1] += x



    C = [0] * N

    C[0] = X[0]

    seen = [False] * N

    stack = deque([0])

    

    while stack:

        v = stack.pop()

        seen[v] = True

        for nv in G[v]:

            if not seen[nv]:

                stack.append(nv)

                C[nv] = C[v] + X[nv]



    print((*C))

    return





if __name__ == '__main__':

    main()

import sys

from collections import deque



read = sys.stdin.buffer.read





def main():

    N, Q, *ABPX = list(map(int, read().split()))

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

    for a, b in zip(ABPX[0 : 2 * N - 2 : 2], ABPX[1 : 2 * N - 2 : 2]):

        G[a - 1].append(b - 1)

        G[b - 1].append(a - 1)

    X = [0] * N

    for p, x in zip(ABPX[2 * N - 2 :: 2], ABPX[2 * N - 1 :: 2]):

        X[p - 1] += x



    C = [0] * N

    C[0] = X[0]

    seen = [False] * N

    stack = deque([0])



    while stack:

        v = stack.pop()

        seen[v] = True

        for nv in G[v]:

            if not seen[nv]:

                stack.append(nv)

                C[nv] = C[v] + X[nv]



    print((*C))

    return





if __name__ == '__main__':

    main()

import sys
from collections import deque

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


def main():
    N, Q = list(map(int, readline().split()))
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = list(map(int, readline().split()))
        G[a - 1].append(b - 1)
        G[b - 1].append(a - 1)
    X = [0] * N
    for i in range(Q):
        p, x = list(map(int, readline().split()))
        X[p - 1] += x
    C = [0] * N
    C[0] = X[0]
    seen = [False] * N
    stack = deque([0])
    while stack:
        v = stack.pop()
        seen[v] = True
        for nv in G[v]:
            if not seen[nv]:
                stack.append(nv)
                C[nv] = C[v] + X[nv]
    print((*C))
    return


if __name__ == "__main__":
    main()

import sys
from collections import deque

read = sys.stdin.buffer.read


def main():
    N, Q, *ABPX = list(map(int, read().split()))
    G = [[] for _ in range(N)]
    for a, b in zip(ABPX[0 : 2 * N - 2 : 2], ABPX[1 : 2 * N - 2 : 2]):
        G[a - 1].append(b - 1)
        G[b - 1].append(a - 1)
    X = [0] * N
    for p, x in zip(ABPX[2 * N - 2 :: 2], ABPX[2 * N - 1 :: 2]):
        X[p - 1] += x
    C = [0] * N
    C[0] = X[0]
    seen = [False] * N
    stack = deque([0])
    while stack:
        v = stack.pop()
        seen[v] = True
        for nv in G[v]:
            if not seen[nv]:
                stack.append(nv)
                C[nv] = C[v] + X[nv]
    print((*C))
    return


if __name__ == "__main__":
    main()

-readline = sys.stdin.readline -sys.setrecursionlimit(10**9) +read = sys.stdin.buffer.read -    N, Q = list(map(int, readline().split())) +    N, Q, *ABPX = list(map(int, read().split())) -    for _ in range(N - 1): -        a, b = list(map(int, readline().split())) +    for a, b in zip(ABPX[0 : 2 * N - 2 : 2], ABPX[1 : 2 * N - 2 : 2]): -    for i in range(Q): -        p, x = list(map(int, readline().split())) +    for p, x in zip(ABPX[2 * N - 2 :: 2], ABPX[2 * N - 1 :: 2]):