local n, q = io.read("*n", "*n")
local edge = {}
local cost = {}
local visited = {}
for i = 1, n do
  edge[i] = {}
  cost[i] = 0
  visited[i] = false
end
for i = 1, n - 1 do
  local a, b = io.read("*n", "*n")
  edge[a][b] = true
  edge[b][a] = true
end
for i = 1, q do
  local p, x = io.read("*n", "*n")
  cost[p] = cost[p] + x
end


local taskstate = {}
for i = 1, n do taskstate[i] = false end
local tasks = {}
local tasknum = 0
local done = 0

local function addtask(idx)
  if not taskstate[idx] then
    taskstate[idx] = true
    tasknum = tasknum + 1
    tasks[tasknum] = idx
    visited[idx] = true
  end
end
addtask(1)

while done < tasknum do
  done = done + 1
  local src = tasks[done]
  taskstate[src] = false
  for dst, unused in pairs(edge[src]) do
    if not visited[dst] then
      cost[dst] = cost[dst] + cost[src]
      addtask(dst)
    end
  end
end
print(table.concat(cost, " "))
