n, q = gets.split.map(&:to_i)
a = Array.new(n - 1){gets.split.map(&:to_i)}.sort_by{|x, y| [x, y]}
p = Array.new(q){gets.split.map(&:to_i)}
h = Hash.new(0)
p.each do |x, y|
  h[x] += y
end
b = Array.new(n + 1, 0)
b[1] = h[1]
que = []
que << 1
while que.size > 0
  u = que.shift
  a.select{|g, _| g == u}.each do |x, y|
    que << y
    b[y] += b[x] + h[y]
  end
end
puts b[1..-1].join(' ')