import sys

import collections





def solve():

    input = sys.stdin.readline

    mod = 10 ** 9 + 7

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

    d = collections.defaultdict(list)

    for i in range(n-1):

        a, b = list(map(int, input().rstrip('\n').split()))

        d[a-1] += [b-1]

        d[b-1] += [a-1]

    ls = [0] * n

    for i in range(q):

        p, x = list(map(int, input().rstrip('\n').split()))

        ls[p-1] += x

    ql = collections.deque([0])

    fq = collections.defaultdict(int)

    fq[0]

    while True:

        if len(ql) != 0:

            p = ql.popleft()

            for v in d[p]:

                if v not in fq:

                    ls[v] += ls[p]

                    ql.appendleft(v)

                    fq[p]

        else:

            print((*ls))

            exit()





if __name__ == '__main__':

    solve()

import sys

import collections





def solve():

    readline = sys.stdin.buffer.readline

    mod = 10 ** 9 + 7



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

    tmd = collections.defaultdict(list)

    for i in range(n-1):

        tma, tmb = list(map(int, readline().split()))

        tmd[tma-1] += [tmb-1]

        tmd[tmb-1] += [tma-1]

    score = [0] * n

    for i in range(q):

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

        score[p-1] += x



    ql = [[0, 0]]

    ql = collections.deque(ql)

    fq = collections.defaultdict(list)

    fq[0]

    while True:

        if len(ql) != 0:

            cost, tmp = ql.popleft()

            for tmv in tmd[tmp]:

                if tmv not in fq:

                    score[tmv] += score[tmp]

                    ql.append([cost + 1, tmv])

                    fq[tmv]

        else:

            break

    print((*score))





if __name__ == '__main__':

    solve()

import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10**9 + 7
    n, q = list(map(int, input().rstrip("\n").split()))
    d = collections.defaultdict(list)
    for i in range(n - 1):
        a, b = list(map(int, input().rstrip("\n").split()))
        d[a - 1] += [b - 1]
        d[b - 1] += [a - 1]
    ls = [0] * n
    for i in range(q):
        p, x = list(map(int, input().rstrip("\n").split()))
        ls[p - 1] += x
    ql = collections.deque([0])
    fq = collections.defaultdict(int)
    fq[0]
    while True:
        if len(ql) != 0:
            p = ql.popleft()
            for v in d[p]:
                if v not in fq:
                    ls[v] += ls[p]
                    ql.appendleft(v)
                    fq[p]
        else:
            print((*ls))
            exit()


if __name__ == "__main__":
    solve()

import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10**9 + 7
    n, q = list(map(int, readline().split()))
    tmd = collections.defaultdict(list)
    for i in range(n - 1):
        tma, tmb = list(map(int, readline().split()))
        tmd[tma - 1] += [tmb - 1]
        tmd[tmb - 1] += [tma - 1]
    score = [0] * n
    for i in range(q):
        p, x = list(map(int, readline().split()))
        score[p - 1] += x
    ql = [[0, 0]]
    ql = collections.deque(ql)
    fq = collections.defaultdict(list)
    fq[0]
    while True:
        if len(ql) != 0:
            cost, tmp = ql.popleft()
            for tmv in tmd[tmp]:
                if tmv not in fq:
                    score[tmv] += score[tmp]
                    ql.append([cost + 1, tmv])
                    fq[tmv]
        else:
            break
    print((*score))


if __name__ == "__main__":
    solve()

-    input = sys.stdin.readline +    readline = sys.stdin.buffer.readline -    n, q = list(map(int, input().rstrip("\n").split())) -    d = collections.defaultdict(list) +    n, q = list(map(int, readline().split())) +    tmd = collections.defaultdict(list) -        a, b = list(map(int, input().rstrip("\n").split())) -        d[a - 1] += [b - 1] -        d[b - 1] += [a - 1] -    ls = [0] * n +        tma, tmb = list(map(int, readline().split())) +        tmd[tma - 1] += [tmb - 1] +        tmd[tmb - 1] += [tma - 1] +    score = [0] * n -        p, x = list(map(int, input().rstrip("\n").split())) -        ls[p - 1] += x -    ql = collections.deque([0]) -    fq = collections.defaultdict(int) +        p, x = list(map(int, readline().split())) +        score[p - 1] += x +    ql = [[0, 0]] +    ql = collections.deque(ql) +    fq = collections.defaultdict(list) -            p = ql.popleft() -            for v in d[p]: -                if v not in fq: -                    ls[v] += ls[p] -                    ql.appendleft(v) -                    fq[p] +            cost, tmp = ql.popleft() +            for tmv in tmd[tmp]: +                if tmv not in fq: +                    score[tmv] += score[tmp] +                    ql.append([cost + 1, tmv]) +                    fq[tmv] -            print((*ls)) -            exit() +            break +    print((*score))