-- D
local N, Q = io.read("*n", "*n")
local edges = {}
for i=1,N do
    edges[i] = {}
end
for i=1,N-1 do
    local a, b = io.read("*n", "*n")
    table.insert(edges[a], b)
    table.insert(edges[b], a)
end

local q = {}
for i=1,N do
    q[i] = 0
end
for i=1,Q do
    local p, x = io.read("*n", "*n")
    q[p] = q[p] + x
end

local counters = {}
for i=1,N do
    counters[i] = 0
end

local task = {}
local seen = {}
local task_insert_ptr = 0
local function task_add(node, accum)
    if not seen[node] then
        seen[node] = true
        task_insert_ptr = task_insert_ptr + 1
        task[task_insert_ptr] = {node, accum}
    end
end
task_add(1, 0)
local task_remove_ptr = 1
local function task_remove()
    local t = task[task_remove_ptr]
    local n, a = t[1], t[2]
    task_remove_ptr = task_remove_ptr + 1
    return n, a
end
while #task >= task_remove_ptr do
    local node, accum = task_remove()
    local inc = q[node]
    counters[node] = accum + inc
    for k, adj in ipairs(edges[node]) do
        task_add(adj, accum + inc)
    end
end

print(table.concat(counters, " "))
