n, q = gets.chomp.split.map(&:to_i)

edges = Array.new(n+1){Array.new}
(n-1).times do
  a, b = gets.chomp.split.map(&:to_i)
  edges[a].push b
  edges[b].push a
end

qhash = {}
qhash.default = 0
q.times do
  a, b = gets.chomp.split.map(&:to_i)
  qhash[a] += b
end

ans = Array.new(n)
ans[1] = qhash[1]
queue = [[1, qhash[1]]]
while !queue.empty?
  e, cost = queue.shift
  edges[e].each do |vol|
    next unless ans[vol].nil?
    new_cost = cost + qhash[vol]
    queue.push [vol, new_cost]
    ans[vol] = new_cost
  end
end

puts ans.slice(1,1000000).join(' ')