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(i, v)
  @tree[i][:v] += v
end

def add_each_child(i, v)
  add(i, v)
  return if @tree[i][:children].size == 0
  @tree[i][:children].each { |j| add_each_child(j, v) }
end

px.each { |p, x| add_each_child(p, x) }

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