object Main extends App {
  val sc = new java.util.Scanner(System.in);
  val n, q = sc.nextInt();
  val abs = Array.fill(n - 1)((sc.nextInt() - 1, sc.nextInt() - 1));
  val pxs = Array.fill(q)((sc.nextInt() - 1, sc.nextInt()));

  val abs2 = Array.fill(n)(Set.empty[Int]);
  abs.foreach { case (a, b) =>
    abs2(a) = abs2(a) + b;
    abs2(b) = abs2(b) + a;
  }

  val answer = Array.fill(n)(0);
  pxs.foreach { case (p, x) =>
    answer(p) += x;
  }
  @scala.annotation.tailrec
  def sub(stack: List[(Int, List[Int])]): Unit = {
    stack match {
      case Nil => ;
      case (_, Nil) :: stack2 => sub(stack2);
      case (parent, h :: tail) :: stack2 =>
        val cs = abs2(h).filter(_ != parent);
        cs.foreach { c =>
          answer(c) += answer(h);
        }
        sub((h, cs.toList) :: (parent, tail) :: stack2);
    }
  }
  sub((-1, List(0)) :: Nil);

  println(answer.mkString(" "));
}