from sys import stdin, setrecursionlimit





def main():



    setrecursionlimit(2000001)



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



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

    for _ in range(current - 1):

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

        tree[a].append(b)

        tree[b].append(a)



    cnt = [0] * (current + 1)

    for _ in range(q):

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

        cnt[parent] += x



    stack = []

    visited = [False] * (current + 1)



    stack.append((0, 1))



    while len(stack) > 0:

        parent, current = stack.pop()

        visited[current] = True

        cnt[current] += cnt[parent]

        for child in tree[current]:

            if not visited[child]:

                stack.append((current, child))



    print((*cnt[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


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