local n, q = io.read("*n", "*n")
local cost = {}
local edge = {}
local asked = {}
for i = 1, n do
  cost[i] = 0
  edge[i] = {}
  asked[i] = false
end
for i = 1, n - 1 do
  local a, b = io.read("*n", "*n")
  table.insert(edge[a], b)
  table.insert(edge[b], a)
end
for iq = 1, q do
  local p, x = io.read("*n", "*n")
  cost[p] = cost[p] + x
end
local tasks = {1}
for i = 1, n do
  local p = tasks[i]
  asked[p] = true
  local e = edge[p]
  for j = 1, #e do
    local c = e[j]
    if not asked[c] then
      table.insert(tasks, c)
      cost[c] = cost[c] + cost[p]
    end
  end
end
print(table.concat(cost, " "))
