N,Q=gets.split.map(&:to_i)
AB=(N-1).times.map{gets.split.map(&:to_i)}.sort_by{|a|a[0]}
PX=Q.times.map{gets.split.map(&:to_i)}

g=Array.new(N){[]}
AB.each do |a, b|
  g[a-1] << b-1
  g[b-1] << a-1
end

checked = Array.new(N, false)
parent = Array.new(N, -1)
zyunban=[]
checked[0] = true
queue = []
g[0].each do |n|
  queue << [0, n]
end
while que = queue.shift
  par, chi = que
  checked[chi] = true
  parent[chi] = par
  zyunban << chi
  
  npar = chi
  g[npar].each do |nchi|
    next if checked[nchi]
    queue << [npar, nchi]
  end
end

ans=Array.new(N, 0)
PX.each do |p, x|
  ans[p-1] += x
end

zyunban.each do |i|
  ans[i] += ans[parent[i]]
end

puts ans.join(" ")