n, q = gets.split.map(&:to_i)
$abs = []
(n - 1).times { $abs << gets.split.map(&:to_i) }
$abs.sort!
pxs = []
q.times { pxs << gets.split.map(&:to_i) }

$res = Hash.new(0)
def add(m, n)
  $res[m] += n
  $abs.each do |a, b|
    break if a > m
    next if a < m
    
    r = add(b, n)
  end
  $res
end

pxs.each do |_p, x|
  $res = add(_p, x)
end

puts (1..n).map { |i| $res[i] }.join(" ")