from sys import stdin, setrecursionlimit

from collections import deque





def main():



    setrecursionlimit(2000001)



    n, q = [int(x) for x in stdin.readline().split()]



    tree = [[] for _ in range(n + 1)]

    for _ in range(n - 1):

        a, b = [int(x) for x in stdin.readline().split()]

        tree[a].append(b)

        tree[b].append(a)



    count = [0] * (n + 1)

    for _ in range(q):

        parent, x = [int(x) for x in stdin.readline().split()]

        count[parent] += x



    queue = deque([])

    visited = [False] * (n + 1)



    queue.append((0, 1))



    while len(queue) > 0:

        parent, current = queue.popleft()

        visited[current] = True

        count[current] += count[parent]

        for child in tree[current]:

            if not visited[child]:

                queue.append((current, child))



    print((*count[1:]))





main()
from sys import stdin, setrecursionlimit

from collections import deque





def main():



    setrecursionlimit(2000001)



    n, q = [int(x) for x in stdin.readline().split()]



    tree = [[] for _ in range(n + 1)]

    for _ in range(n - 1):

        a, b = [int(x) for x in stdin.readline().split()]

        tree[a].append(b)

        tree[b].append(a)



    count = [0] * (n + 1)

    for _ in range(q):

        parent, x = [int(x) for x in stdin.readline().split()]

        count[parent] += x



    queue = deque([])

    visited = [False] * (n + 1)



    queue.append((0, 1))



    while len(queue) > 0:

        parent, current = queue.pop()

        visited[current] = True

        count[current] += count[parent]

        for child in tree[current]:

            if not visited[child]:

                queue.append((current, child))



    print((*count[1:]))





main()
from sys import stdin, setrecursionlimit
from collections import deque


def main():
    setrecursionlimit(2000001)
    n, q = [int(x) for x in stdin.readline().split()]
    tree = [[] for _ in range(n + 1)]
    for _ in range(n - 1):
        a, b = [int(x) for x in stdin.readline().split()]
        tree[a].append(b)
        tree[b].append(a)
    count = [0] * (n + 1)
    for _ in range(q):
        parent, x = [int(x) for x in stdin.readline().split()]
        count[parent] += x
    queue = deque([])
    visited = [False] * (n + 1)
    queue.append((0, 1))
    while len(queue) > 0:
        parent, current = queue.popleft()
        visited[current] = True
        count[current] += count[parent]
        for child in tree[current]:
            if not visited[child]:
                queue.append((current, child))
    print((*count[1:]))


main()

from sys import stdin, setrecursionlimit
from collections import deque


def main():
    setrecursionlimit(2000001)
    n, q = [int(x) for x in stdin.readline().split()]
    tree = [[] for _ in range(n + 1)]
    for _ in range(n - 1):
        a, b = [int(x) for x in stdin.readline().split()]
        tree[a].append(b)
        tree[b].append(a)
    count = [0] * (n + 1)
    for _ in range(q):
        parent, x = [int(x) for x in stdin.readline().split()]
        count[parent] += x
    queue = deque([])
    visited = [False] * (n + 1)
    queue.append((0, 1))
    while len(queue) > 0:
        parent, current = queue.pop()
        visited[current] = True
        count[current] += count[parent]
        for child in tree[current]:
            if not visited[child]:
                queue.append((current, child))
    print((*count[1:]))


main()

-        parent, current = queue.popleft() +        parent, current = queue.pop()