from sys import stdin, setrecursionlimit





def main():



    def walk(p, c):

        if visited[p]:

            return

        visited[p] = True

        cnt[p] += c

        for n in tree[p]:

            walk(n, cnt[p])



    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)



    cnt = [0] * (n + 1)

    for _ in range(q):

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

        cnt[p] += x



    visited = [False] * (n + 1)

    walk(1, 0)



    for i in range(1, n + 1):

        print(cnt[i], end=" ")



main()

from sys import stdin

from collections import deque

def main():

  _map, _input, _int = map, stdin.readline, int

  n, q = _map(_int, _input().split())

  values = [0] * n

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

  for _ in range(n - 1):

    a, b = _map(_int, _input().split())

    if a >= b:

      return

    links[a - 1].append(b - 1)

    links[b - 1].append(a - 1)

  for _ in range(q):

    p, x = _map(_int, _input().split())

    values[p - 1] += x

  d = deque()

  d.append((0, -1))

  while len(d) != 0:

    i, p = d.popleft()

    for j in links[i]:

      if j == p:

        continue

      values[j] += values[i]

      d.append((j, i))

  print((*values))

main()
from sys import stdin, setrecursionlimit


def main():
    def walk(p, c):
        if visited[p]:
            return
        visited[p] = True
        cnt[p] += c
        for n in tree[p]:
            walk(n, cnt[p])

    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)
    cnt = [0] * (n + 1)
    for _ in range(q):
        p, x = [int(x) for x in stdin.readline().split()]
        cnt[p] += x
    visited = [False] * (n + 1)
    walk(1, 0)
    for i in range(1, n + 1):
        print(cnt[i], end=" ")


main()

from sys import stdin
from collections import deque


def main():
    _map, _input, _int = map, stdin.readline, int
    n, q = _map(_int, _input().split())
    values = [0] * n
    links = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = _map(_int, _input().split())
        if a >= b:
            return
        links[a - 1].append(b - 1)
        links[b - 1].append(a - 1)
    for _ in range(q):
        p, x = _map(_int, _input().split())
        values[p - 1] += x
    d = deque()
    d.append((0, -1))
    while len(d) != 0:
        i, p = d.popleft()
        for j in links[i]:
            if j == p:
                continue
            values[j] += values[i]
            d.append((j, i))
    print((*values))


main()

-from sys import stdin, setrecursionlimit +from sys import stdin +from collections import deque -    def walk(p, c): -        if visited[p]: +    _map, _input, _int = map, stdin.readline, int +    n, q = _map(_int, _input().split()) +    values = [0] * n +    links = [[] for _ in range(n)] +    for _ in range(n - 1): +        a, b = _map(_int, _input().split()) +        if a >= b: -        visited[p] = True -        cnt[p] += c -        for n in tree[p]: -            walk(n, cnt[p]) - -    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) -    cnt = [0] * (n + 1) +        links[a - 1].append(b - 1) +        links[b - 1].append(a - 1) -        p, x = [int(x) for x in stdin.readline().split()] -        cnt[p] += x -    visited = [False] * (n + 1) -    walk(1, 0) -    for i in range(1, n + 1): -        print(cnt[i], end=" ") +        p, x = _map(_int, _input().split()) +        values[p - 1] += x +    d = deque() +    d.append((0, -1)) +    while len(d) != 0: +        i, p = d.popleft() +        for j in links[i]: +            if j == p: +                continue +            values[j] += values[i] +            d.append((j, i)) +    print((*values))