import scala.io.StdIn

case class Node(n: Int, var x: Int = 0, var subs: List[Node] = List()) {
  def addSub(sub: Node): Unit = this.subs +:= sub

  def trace(acc: Long, additions: Array[Int], result: Array[Long]): Array[Long] = {
    val _acc = acc + additions(n).toLong
    result(n) = _acc
    subs.foreach(_.trace(_acc, additions, result))
    result
  }

  override def toString: String = s"{ $n | +$x | (${subs.mkString(", ")}) }"
}

object Main extends App {
  val Array(n, q) = StdIn.readLine.split(" ").map(_.toInt)
  val abs = fromStdIn(n - 1)
  val pxs = fromStdIn(q)

  val nodes: Array[Node] = Array.ofDim(n + 1)
  nodes(1) = Node(1)
  abs.foreach { case (a, b) =>
    if (nodes(a) != null && nodes(b) == null) {
      val node = Node(b)
      nodes(a).addSub(node)
      nodes(b) = node

    } else if (nodes(a) == null && nodes(b) != null) {
      val node = Node(a)
      nodes(b).addSub(Node(a))
      nodes(a) = node
    } else if (nodes(a) == null && nodes(b) == null) {
      nodes(a) = Node(a)
      nodes(b) = Node(b)
    } else {
      1 / 0
    }
  }

  val additions = Array.ofDim[Int](n + 1)
  for ((p, x) <- pxs) {
    additions(p) += x
  }

  val result = Array.ofDim[Long](n + 1)
  nodes(1).trace(0L, additions, result)

  println(result.tail.mkString(" "))

  def fromStdIn(n: Int): Seq[(Int, Int)] =
    for (_ <- 1 to n)
      yield {
        val line = StdIn.readLine.split(" ").map(_.toInt)
        (line(0), line(1))
      }
}
