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

ab = [list(map(int, input().split())) for _ in range(n-1)]

px = [list(map(int, input().split())) for _ in range(q)]

dp = [0] * n

ls = [[] for i in range(n)]

for i in ab:

    ls[i[0]-1].append(i[1]-1)

for i in px:

    dp[i[0]-1] += i[1]

for i in range(n):

    for j in ls[i]:

        dp[j] += dp[i]

print((*dp))

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 for _ in range(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()

n, q = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n - 1)]
px = [list(map(int, input().split())) for _ in range(q)]
dp = [0] * n
ls = [[] for i in range(n)]
for i in ab:
    ls[i[0] - 1].append(i[1] - 1)
for i in px:
    dp[i[0] - 1] += i[1]
for i in range(n):
    for j in ls[i]:
        dp[j] += dp[i]
print((*dp))

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 for _ in range(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()

-n, q = list(map(int, input().split())) -ab = [list(map(int, input().split())) for _ in range(n - 1)] -px = [list(map(int, input().split())) for _ in range(q)] -dp = [0] * n -ls = [[] for i in range(n)] -for i in ab: -    ls[i[0] - 1].append(i[1] - 1) -for i in px: -    dp[i[0] - 1] += i[1] -for i in range(n): -    for j in ls[i]: -        dp[j] += dp[i] -print((*dp)) +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 for _ in range(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()