def get_children(parent)
  children = $childrens[parent]
  return children if $already[parent]

  $already[parent] = true
  return $childrens[parent] = children + children.map{|i| get_children(i)}.flatten
end

N, Q = gets.split.map(&:to_i)
merge_arrs = (N-1).times.map{gets.split.map(&:to_i)}
add_point_arrs = Q.times.map{gets.split.map(&:to_i)}
$already = Array.new(N + 1, false)
$childrens = Array.new(N + 1).map{Array.new(0)}

merge_arrs.each do |parent, child|
  $childrens[parent].push(child)
end

points = Array.new(N + 1, 0)
add_point_arrs.each do |parent, point|
  children = get_children(parent)

  points[parent] += point
  children.each do |pos|
    points[pos] += point
  end
end

points.shift
puts points.join(' ')