import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, Q = in.next().toInt
  val graph = Array.fill[List[Int]](N+1)(Nil)
  for (_ <- 1 to N-1) {
    val a, b = in.next().toInt
    graph(a) = b :: graph(a)
    graph(b) = a :: graph(b)
  }
  val count = new Array[Int](N+1)
  for (_ <- 1 to Q) {
    val p, x = in.next().toInt
    count(p) += x
  }

  //
  val q = Queue[(Int, Long)]((1, 0)) // (node, total)
  val ans = Array.fill[Long](N+1)(-1)
  while (!q.isEmpty) {
    val (now, _cost) = q.dequeue()
    if (ans(now) == -1) {
      val cost = _cost + count(now)
      ans(now) = cost
      for (e <- graph(now)) {
        q.enqueue((e, cost))
      }
    }
  }

  println(ans.drop(1).mkString(" "))
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
