import scala.io.StdIn

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

  val subsArray = Array.fill[Seq[Int]](n + 1)(Seq())
  abs.groupBy(_._1).foreach {
    case (i, subs) => subsArray(i) = subs.map(_._2)
  }

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

  val result = Array.fill[Int](n + 1)(0)

  def rec(n: Int, acc: Int): Unit = {
    val _acc = acc + addsArray(n)
    result(n) = _acc
    subsArray(n).foreach(sub => rec(sub, _acc))
  }

  rec(1, 0)

  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))
      }
}
