class Node
  attr_accessor :n, :c, :val
  def initialize(n)
    @n = n
    @c = []
    @val = 0
  end
  def sum
    @c.each do |child|
      child.val += @val
      child.sum
    end
  end
  def to_s
    @val.to_s
  end
end

n, q = ARGF.gets.split.map(&:to_i)
nodes = Array.new(n+1) { |m| Node.new(m) }

(n-1).times do
    a, b = ARGF.gets.split.map(&:to_i)
    nodes[a].c << nodes[b]
end
q.times do
    p, x = ARGF.gets.split.map(&:to_i)
    nodes[p].val += x
end

nodes[1].sum
nodes.shift
puts nodes.map(&:to_s).join(' ')
