import sys

from collections import deque



input = sys.stdin.readline





def bfs(G, v, p, counter):

    queue = deque([(v, p)])

    while queue:

        v, p = queue.popleft()

        for c in G[v]:

            if c == p:

                continue

            counter[c] += counter[v]

            queue.append((c, v))





def main():

    N, Q = list(map(int, input().split()))



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

    for _ in range(N - 1):

        a, b = list(map(int, input().split()))

        a -= 1

        b -= 1

        G[a].append(b)

        G[b].append(a)



    counter = [0] * N

    for _ in range(Q):

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

        p -= 1

        counter[p] += x



    bfs(G, 0, -1, counter)



    print((" ".join(map(str, counter))))





if __name__ == "__main__":

    main()

import sys

from collections import deque



input = sys.stdin.readline





def bfs(G, v, p, counter):

    queue = deque([(v, p)])

    while queue:

        v, p = queue.popleft()

        for c in G[v]:

            if c == p:

                continue

            counter[c] += counter[v]

            queue.append((c, v))





def main():

    N, Q = list(map(int, input().split()))



    G = [[] for _ in range(N + 1)]

    for _ in range(N - 1):

        a, b = list(map(int, input().split()))

        G[a].append(b)

        G[b].append(a)



    counter = [0] * (N + 1)

    for _ in range(Q):

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

        counter[p] += x



    bfs(G, 1, -1, counter)



    print((" ".join(map(str, counter[1:]))))





if __name__ == "__main__":

    main()

import sys
from collections import deque

input = sys.stdin.readline


def bfs(G, v, p, counter):
    queue = deque([(v, p)])
    while queue:
        v, p = queue.popleft()
        for c in G[v]:
            if c == p:
                continue
            counter[c] += counter[v]
            queue.append((c, v))


def main():
    N, Q = list(map(int, input().split()))
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = list(map(int, input().split()))
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)
    counter = [0] * N
    for _ in range(Q):
        p, x = list(map(int, input().split()))
        p -= 1
        counter[p] += x
    bfs(G, 0, -1, counter)
    print((" ".join(map(str, counter))))


if __name__ == "__main__":
    main()

import sys
from collections import deque

input = sys.stdin.readline


def bfs(G, v, p, counter):
    queue = deque([(v, p)])
    while queue:
        v, p = queue.popleft()
        for c in G[v]:
            if c == p:
                continue
            counter[c] += counter[v]
            queue.append((c, v))


def main():
    N, Q = list(map(int, input().split()))
    G = [[] for _ in range(N + 1)]
    for _ in range(N - 1):
        a, b = list(map(int, input().split()))
        G[a].append(b)
        G[b].append(a)
    counter = [0] * (N + 1)
    for _ in range(Q):
        p, x = list(map(int, input().split()))
        counter[p] += x
    bfs(G, 1, -1, counter)
    print((" ".join(map(str, counter[1:]))))


if __name__ == "__main__":
    main()

-    G = [[] for _ in range(N)] +    G = [[] for _ in range(N + 1)] -        a -= 1 -        b -= 1 -    counter = [0] * N +    counter = [0] * (N + 1) -        p -= 1 -    bfs(G, 0, -1, counter) -    print((" ".join(map(str, counter)))) +    bfs(G, 1, -1, counter) +    print((" ".join(map(str, counter[1:]))))