n, q = gets.split.map(&:to_i)
ab = []
(n-1).times {|_x| ab << gets.split.map(&:to_i)}
ab.sort!
px =
  readlines.map do |i|
    i.chomp.split.map(&:to_i)
  end.to_a

children = []
prev_parent = ab[0][0]
tmp_arr=[]
ab.each do |a,b|
  if prev_parent == a
    tmp_arr << b
  else
    children << tmp_arr
    tmp_arr=[b]
  end

  prev_parent=a
end
children << tmp_arr
#puts children.to_s

ans = [0]*n
px.each do |pp,point|
  ans[pp-1]+=point
end

children.each_with_index do |child,i|
  child.each do |index|
    ans[index-1]+=ans[i]
  end
end

puts ans.join(' ')