import java.util.concurrent.LinkedBlockingQueue


fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val (n, q) = intList()
    class Vertex(val myNumber: Int) {
        private var connectedNode: MutableList<Vertex> = mutableListOf()
        private var count: Long = 0L
        fun addConnectedNode(v: Vertex) {
            connectedNode.add(v)
        }
        fun connectedNode() = connectedNode

        fun addCount(c: Long) {
            count += c
        }
        fun count() = count
    }

    val v = Array(n) { Vertex(it) }
    repeat(n - 1) {
        val (a, b) = intList()
        v[a - 1].addConnectedNode(v[b - 1])
        v[b - 1].addConnectedNode(v[a - 1])
    }
    repeat(q) {
        val (p, x) = intList()
        v[p - 1].addCount(x.toLong())
    }
    val counts = Array(n) { 0L }
    val visited = Array(n) { false }
    val queue = LinkedBlockingQueue<Vertex>()
    queue.offer(v.first())
    while (queue.isNotEmpty()) {
        val vv = queue.poll()
        val count = vv.count()
        counts[vv.myNumber] = count
        visited[vv.myNumber] = true
        vv.connectedNode().forEach {
            if (!visited[it.myNumber]) {
                it.addCount(count)
                queue.offer(it)
            }
        }
    }
    println(counts.joinToString(" "))
}
