import java.io.PrintWriter

fun main(args: Array<String>) = Thread(null, ::abc138d_test, "", 64 * 1024 * 1024).start()

@OptIn(ExperimentalStdlibApi::class)
fun abc138d_test() {

    val pw = PrintWriter(System.out)

    val (n, q) = readLine()!!.split(' ').map { it.toInt() }

    val paths = Array(n) { java.util.ArrayDeque<Int>() }
    val values = IntArray(n) { 0 }

    repeat(n - 1) {
        val line = readLine()!!.split(' ').map { it.toInt() }
        paths[line[0] - 1].add(line[1] - 1)
        paths[line[1] - 1].add(line[0] - 1)
    }

    repeat(q) {
        val line = readLine()!!.split(' ').map { it.toInt() }
        values[line[0] - 1] += line[1]
    }
    val visited = BooleanArray(n) { false }

    fun dfs(i: Int) {
        visited[i] = true

        repeat(paths[i].size) {
            val index = paths[i].poll()
            if (!visited[index]) {
                values[index] += values[i]
                dfs(index)
            }
        }
    }

    dfs(0)

    pw.print(values[0])
    values.drop(1).forEach {
        pw.print(" $it")
    }

    pw.println()
    pw.flush()
}
