n, q = gets.chomp.split.map(&:to_i)
h = []
ans = Array.new(n, 0)
rel = Array.new(n) { [] }
(n-1).times do
  a, b = gets.chomp.split.map(&:to_i)
  a -= 1
  b -= 1
  rel[a].push(b)
  rel[b].push(a)
end

q.times do
  a, b = gets.chomp.split.map(&:to_i)
  ans[a-1] += b
end

fin = Array.new(n, false)
queue = [0]
while !queue.empty?
  n = queue.shift
  fin[n] = true
  rel[n].each do |t|
    next if fin[t]
    ans[t] += ans[n]
    queue.push(t)
  end
end

puts ans.join(' ')
