def slove():

    import sys

    import collections

    input = sys.stdin.readline

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



    ls = collections.defaultdict(list)

    ls[1]

    for i in range(n-1):

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

        ls[a] += [b]

        ls[b] += [a]



    ans = [0] * n

    for i in range(qq):

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

        ans[p-1] += x



    q = collections.deque()

    q.append(1)

    fq = collections.defaultdict(list)

    while True:

        if len(q) != 0:

            p = q.popleft()

            fq[p]

            for i in ls[p]:

                if i not in fq:

                    q.append(i)

                    ans[i-1] += ans[p-1]

        else:

            break

    print((*ans))





if __name__ == '__main__':

    slove()

def slove():

    import sys

    import collections

    input = sys.stdin.readline

    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] += [b]

        d[b] += [a]



    score = collections.defaultdict(int)

    for i in range(q):

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

        score[p] += x



    ql = collections.deque()

    ql.append(1)

    fq = collections.defaultdict(list)

    fq[1]

    while True:

        if len(ql) != 0:

            p = ql.popleft()

            for v in d[p]:

                if v not in fq:

                    score[v] += score[p]

                    fq[v]

                    ql.append(v)

        else:

            break

    print((*[score[i] for i in range(1, n + 1)]))





if __name__ == '__main__':

    slove()

def slove():
    import sys
    import collections

    input = sys.stdin.readline
    n, qq = list(map(int, input().rstrip("\n").split()))
    ls = collections.defaultdict(list)
    ls[1]
    for i in range(n - 1):
        a, b = list(map(int, input().rstrip("\n").split()))
        ls[a] += [b]
        ls[b] += [a]
    ans = [0] * n
    for i in range(qq):
        p, x = list(map(int, input().rstrip("\n").split()))
        ans[p - 1] += x
    q = collections.deque()
    q.append(1)
    fq = collections.defaultdict(list)
    while True:
        if len(q) != 0:
            p = q.popleft()
            fq[p]
            for i in ls[p]:
                if i not in fq:
                    q.append(i)
                    ans[i - 1] += ans[p - 1]
        else:
            break
    print((*ans))


if __name__ == "__main__":
    slove()

def slove():
    import sys
    import collections

    input = sys.stdin.readline
    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] += [b]
        d[b] += [a]
    score = collections.defaultdict(int)
    for i in range(q):
        p, x = list(map(int, input().rstrip("\n").split()))
        score[p] += x
    ql = collections.deque()
    ql.append(1)
    fq = collections.defaultdict(list)
    fq[1]
    while True:
        if len(ql) != 0:
            p = ql.popleft()
            for v in d[p]:
                if v not in fq:
                    score[v] += score[p]
                    fq[v]
                    ql.append(v)
        else:
            break
    print((*[score[i] for i in range(1, n + 1)]))


if __name__ == "__main__":
    slove()

-    n, qq = list(map(int, input().rstrip("\n").split())) -    ls = collections.defaultdict(list) -    ls[1] +    n, q = list(map(int, input().rstrip("\n").split())) +    d = collections.defaultdict(list) -        ls[a] += [b] -        ls[b] += [a] -    ans = [0] * n -    for i in range(qq): +        d[a] += [b] +        d[b] += [a] +    score = collections.defaultdict(int) +    for i in range(q): -        ans[p - 1] += x -    q = collections.deque() -    q.append(1) +        score[p] += x +    ql = collections.deque() +    ql.append(1) +    fq[1] -        if len(q) != 0: -            p = q.popleft() -            fq[p] -            for i in ls[p]: -                if i not in fq: -                    q.append(i) -                    ans[i - 1] += ans[p - 1] +        if len(ql) != 0: +            p = ql.popleft() +            for v in d[p]: +                if v not in fq: +                    score[v] += score[p] +                    fq[v] +                    ql.append(v) -    print((*ans)) +    print((*[score[i] for i in range(1, n + 1)]))