require 'pp'

class T < Array
  def initialize(n)
    super(n+1) { [] }
  end
  def shrink(n)
    self[n].each { |m| self[n] += self.shrink(m) }
	self[n]
  end
end

n, q = ARGF.gets.split.map(&:to_i)
t = T.new(n)
(n-1).times do
  a, b = ARGF.gets.split.map(&:to_i)
  t[a] << b
end

t.shrink(1)

#pp t

c = Array.new(n+1, 0)

q.times do
  p, x = ARGF.gets.split.map(&:to_i)
  t[p].each {|q| c[q] += x}
end

c.shift
puts "#{c}"