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 = {}
(1..n).each { |i| @tree[i] = { v: 0, children: [] } }

ab.each { |a, b| @tree[a][:children] << b }

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

px.each do |p, x|
  @tree[p][:v] += x
end

add_each_child(1, @tree[1][:children])

puts @tree.values.map { |v| v[:v] }.join(' ')
