n,q = gets.split.map(&:to_i)
a = []
b = []
(n-1).times do |i|
  a[i],b[i] = gets.split.map(&:to_i)
end
p = []
x = []
q.times do |i|
  p[i],x[i] = gets.split.map(&:to_i)
end

result = []
(1..n).each do |i|
  p_index = p.index(i)
  if p_index.nil?
    result[i-1] = 0
    next
  end
  result[i-1] = x[p_index.to_i] || 0
end

(n-1).times do |i|
  a_i = a[i].to_i
  b_i = b[i].to_i
  result[b_i-1] += result[a_i-1]
end

puts "#{result.join(" ")}"