import java.util.*

data class NodeValue(
  var x: Long = 0L,
  var v: Long = 0L
)

class Node {
  val value = NodeValue()
  val edges = mutableListOf<Int>()

  fun addEdge(to: Int) {
    edges.add(to)
  }
}

class Graph(N: Int) {
  private val nodes = Array(N) { Node() }

  fun addEdge(a: Int, b: Int) {
    nodes[a - 1].addEdge(b)
    nodes[b - 1].addEdge(a)
  }

  fun getNode(i: Int) = nodes[i - 1]
}

fun main() {
  val (N, Q) = readInts()
  val ab = (1 until N).map { readInts() }
  val px = (1..Q).map { readInts() }

  val g = Graph(N)
  ab.forEach { g.addEdge(it[0], it[1]) }
  px.forEach { g.getNode(it[0]).value.x += it[1] }

  val result = Array(N) { 0L }
  val queue = ArrayDeque<Triple<Int, Int, Long>>()
  queue.add(Triple(0, 1, 0L))
  while (queue.isNotEmpty()) {
    val (from, to, sum) = queue.pop()
    val node = g.getNode(to)
    node.value.v = sum + node.value.x
    result[to - 1] = node.value.v
    node.edges.filter { it != from }.forEach { queue.add(Triple(to, it, node.value.v)) }
  }

  println(result.joinToString(" "))
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readStrings() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
