from collections import deque



def main():

    n, q = list(map(int, input().split()))

    a = [[] for _ in range(n)]

    for i in range(n - 1):

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

        a[x - 1].append(y - 1)

        a[y - 1].append(x - 1)

    p = [0] * n

    for i in range(q):

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

        p[x - 1] += y

    c = [0] * n

    c[0] = 1

    que = deque([])

    que.append(0)

    while len(que) > 0:

        e = que.popleft()

        for i in a[e]:

            if c[i] > 0:

                continue

            c[i] = 1

            p[i] += p[e]

            que.append(i)

    for i in range(n):

        print((p[i]))

main()
from sys import stdin



def main():

    from collections import deque

    input = stdin.readline

    n, q = list(map(int, input().split()))

    a = [[] for _ in range(n)]

    for i in range(n - 1):

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

        a[x - 1].append(y - 1)

        a[y - 1].append(x - 1)

    p = [0] * n

    for i in range(q):

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

        p[x - 1] += y

    c = [0] * n

    c[0] = 1

    que = deque([])

    que.append(0)

    while len(que) > 0:

        e = que.popleft()

        for i in a[e]:

            if c[i] > 0:

                continue

            c[i] = 1

            p[i] += p[e]

            que.append(i)

    for i in range(n):

        print((p[i]))

main()
from collections import deque


def main():
    n, q = list(map(int, input().split()))
    a = [[] for _ in range(n)]
    for i in range(n - 1):
        x, y = list(map(int, input().split()))
        a[x - 1].append(y - 1)
        a[y - 1].append(x - 1)
    p = [0] * n
    for i in range(q):
        x, y = list(map(int, input().split()))
        p[x - 1] += y
    c = [0] * n
    c[0] = 1
    que = deque([])
    que.append(0)
    while len(que) > 0:
        e = que.popleft()
        for i in a[e]:
            if c[i] > 0:
                continue
            c[i] = 1
            p[i] += p[e]
            que.append(i)
    for i in range(n):
        print((p[i]))


main()

from sys import stdin


def main():
    from collections import deque

    input = stdin.readline
    n, q = list(map(int, input().split()))
    a = [[] for _ in range(n)]
    for i in range(n - 1):
        x, y = list(map(int, input().split()))
        a[x - 1].append(y - 1)
        a[y - 1].append(x - 1)
    p = [0] * n
    for i in range(q):
        x, y = list(map(int, input().split()))
        p[x - 1] += y
    c = [0] * n
    c[0] = 1
    que = deque([])
    que.append(0)
    while len(que) > 0:
        e = que.popleft()
        for i in a[e]:
            if c[i] > 0:
                continue
            c[i] = 1
            p[i] += p[e]
            que.append(i)
    for i in range(n):
        print((p[i]))


main()

-from collections import deque +from sys import stdin +    from collections import deque + +    input = stdin.readline