#python3

from collections import deque 

def main():

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

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

    for _ in range(n-1):

        a, b = map(lambda x: int(x)-1, input().split())

        to[a].append(b)

        to[b].append(a)



    node = [0 for _ in range(n)]



    for _ in range(q):

        p, x = map(int, input().split())

        node[p-1] += x



    dq = deque() 

    dq.append(0)

    done = [0 for _ in range(n)]

    done[0] = 1

    while len(dq) > 0:

        x = dq.popleft()

        for i in to[x]:

            if done[i] == 1:

                continue

            node[i] += node[x]

            done[i] = 1 

            dq.append(i)



    for i in range(n):

        print(node[i]) if i == n-1 else print(node[i], end=' ')

main()

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

from copy import deepcopy

from collections import deque

def main():

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

    m = map(int, read().split())

    n = deepcopy(m)

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

    for a, b in [(a-1, b-1) for a, b in zip(m, m)][:N-1]:

        to[a].append(b)

        to[b].append(a)

    score = [0 for _ in range(N)]

    for p, x in [(p-1, x) for p, x in zip(n, n)][N-1:]:

        score[p] += x



    dq = deque()

    dq.append(0)

    done = [0 for _ in range(N)]

    done[0] = 1

    while len(dq)>0:

        node = dq.popleft()

        for nx in to[node]: 

            if done[nx] == 1:

                continue 

            done[nx] = 1

            score[nx] += score[node]

            dq.append(nx)

    for i in score:

        print(i, end=' ')

if __name__ == '__main__':

    main()

# python3
from collections import deque


def main():
    n, q = map(int, input().split())
    to = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = map(lambda x: int(x) - 1, input().split())
        to[a].append(b)
        to[b].append(a)
    node = [0 for _ in range(n)]
    for _ in range(q):
        p, x = map(int, input().split())
        node[p - 1] += x
    dq = deque()
    dq.append(0)
    done = [0 for _ in range(n)]
    done[0] = 1
    while len(dq) > 0:
        x = dq.popleft()
        for i in to[x]:
            if done[i] == 1:
                continue
            node[i] += node[x]
            done[i] = 1
            dq.append(i)
    for i in range(n):
        print(node[i]) if i == n - 1 else print(node[i], end=" ")


main()

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from copy import deepcopy
from collections import deque


def main():
    N, Q = map(int, readline().split())
    m = map(int, read().split())
    n = deepcopy(m)
    to = [[] for _ in range(N)]
    for a, b in [(a - 1, b - 1) for a, b in zip(m, m)][: N - 1]:
        to[a].append(b)
        to[b].append(a)
    score = [0 for _ in range(N)]
    for p, x in [(p - 1, x) for p, x in zip(n, n)][N - 1 :]:
        score[p] += x
    dq = deque()
    dq.append(0)
    done = [0 for _ in range(N)]
    done[0] = 1
    while len(dq) > 0:
        node = dq.popleft()
        for nx in to[node]:
            if done[nx] == 1:
                continue
            done[nx] = 1
            score[nx] += score[node]
            dq.append(nx)
    for i in score:
        print(i, end=" ")


if __name__ == "__main__":
    main()

-# python3 +import sys + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +from copy import deepcopy -    n, q = map(int, input().split()) -    to = [[] for _ in range(n)] -    for _ in range(n - 1): -        a, b = map(lambda x: int(x) - 1, input().split()) +    N, Q = map(int, readline().split()) +    m = map(int, read().split()) +    n = deepcopy(m) +    to = [[] for _ in range(N)] +    for a, b in [(a - 1, b - 1) for a, b in zip(m, m)][: N - 1]: -    node = [0 for _ in range(n)] -    for _ in range(q): -        p, x = map(int, input().split()) -        node[p - 1] += x +    score = [0 for _ in range(N)] +    for p, x in [(p - 1, x) for p, x in zip(n, n)][N - 1 :]: +        score[p] += x -    done = [0 for _ in range(n)] +    done = [0 for _ in range(N)] -        x = dq.popleft() -        for i in to[x]: -            if done[i] == 1: +        node = dq.popleft() +        for nx in to[node]: +            if done[nx] == 1: -            node[i] += node[x] -            done[i] = 1 -            dq.append(i) -    for i in range(n): -        print(node[i]) if i == n - 1 else print(node[i], end=" ") +            done[nx] = 1 +            score[nx] += score[node] +            dq.append(nx) +    for i in score: +        print(i, end=" ") -main() +if __name__ == "__main__": +    main()