n, q = gets.chomp.split(' ').map(&:to_i)
ab = (1..(n - 1)).map { gets.chomp.split(' ').map(&:to_i) }
px = (1..q).map { gets.chomp.split(' ').map(&:to_i) }.sort_by { |p, _| p }

@tree = {}
@answer = {}
(1..n).each do |i|
  @tree[i] = []
  @answer[i] = 0
end

ab.each { |a, b| @tree[a] << b }
px.each { |p, x| @answer[p] += x }

def add_each_child(p, children)
  return if children.size == 0
  children.each do |i|
    @answer[i] += @answer[p]
    add_each_child(i, @tree[i])
  end
end

add_each_child(1, @tree[1])

puts @answer.values.join(' ')
