import sys

input = sys.stdin.readline



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

ab = [list(map(int, input().split())) for _ in range(N - 1)]

px = [list(map(int, input().split())) for _ in range(Q)]



class Tree:

  C = {}

  N, D = None, None

  def __init__(s, num):

    s.N = num

  def setC(s, a, b):

    if a in s.C: s.C[a].append(b)

    else: s.C[a] = [b]

    if b in s.C: s.C[b].append(a)

    else: s.C[b] = [a]

  def exe(s):

    L = [-1] * N

    A = [0] * N

    for p, x in px:

      p -= 1

      A[p] += x

    S = [0]

    while S != []:

      t = S.pop()

      L[t] = 1

      for i in s.C[t]:

        if L[i] == -1:

          L[i] = 1

          A[i] += A[t]

          S.append(i)

    for i in range(N):

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



T = Tree(N)

for a, b in ab:

  a -= 1

  b -= 1

  T.setC(a, b)



T.exe()



import sys

input = sys.stdin.readline



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

ab = [list(map(int, input().split())) for _ in range(N - 1)]

px = [list(map(int, input().split())) for _ in range(Q)]



class Tree:

  C = {}

  N, D = None, None

  def __init__(s, num):

    s.N = num

  def setC(s, a, b):

    if a in s.C: s.C[a].append(b)

    else: s.C[a] = [b]

    if b in s.C: s.C[b].append(a)

    else: s.C[b] = [a]

  def exe(s):

    L = [-1] * N

    A = [0] * N

    for p, x in px:

      p -= 1

      A[p] += x

    S = [0]

    while S != []:

      t = S.pop()

      L[t] = 1

      for i in s.C[t]:

        if L[i] == -1:

          A[i] += A[t]

          S.append(i)

    for i in range(N):

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



T = Tree(N)

for a, b in ab:

  a -= 1

  b -= 1

  T.setC(a, b)



T.exe()



import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]


class Tree:
    C = {}
    N, D = None, None

    def __init__(s, num):
        s.N = num

    def setC(s, a, b):
        if a in s.C:
            s.C[a].append(b)
        else:
            s.C[a] = [b]
        if b in s.C:
            s.C[b].append(a)
        else:
            s.C[b] = [a]

    def exe(s):
        L = [-1] * N
        A = [0] * N
        for p, x in px:
            p -= 1
            A[p] += x
        S = [0]
        while S != []:
            t = S.pop()
            L[t] = 1
            for i in s.C[t]:
                if L[i] == -1:
                    L[i] = 1
                    A[i] += A[t]
                    S.append(i)
        for i in range(N):
            print(A[i], end=" ")


T = Tree(N)
for a, b in ab:
    a -= 1
    b -= 1
    T.setC(a, b)
T.exe()

import sys

input = sys.stdin.readline
N, Q = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]


class Tree:
    C = {}
    N, D = None, None

    def __init__(s, num):
        s.N = num

    def setC(s, a, b):
        if a in s.C:
            s.C[a].append(b)
        else:
            s.C[a] = [b]
        if b in s.C:
            s.C[b].append(a)
        else:
            s.C[b] = [a]

    def exe(s):
        L = [-1] * N
        A = [0] * N
        for p, x in px:
            p -= 1
            A[p] += x
        S = [0]
        while S != []:
            t = S.pop()
            L[t] = 1
            for i in s.C[t]:
                if L[i] == -1:
                    A[i] += A[t]
                    S.append(i)
        for i in range(N):
            print(A[i], end=" ")


T = Tree(N)
for a, b in ab:
    a -= 1
    b -= 1
    T.setC(a, b)
T.exe()

-                    L[i] = 1