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

class MyLib
  def add(num,point,children,ans)
    # そのノード
    ans[num-1]+=point

    return if children.size < num
    inds = children[num-1]
    inds.each{|i| add(i,point,children,ans)}
  end
end

ans = [0]*n
myl = MyLib.new
px.each do |pp,point|
  myl.add(pp,point,children,ans)
end

puts ans.join(' ')