N,Q = gets.split.map(&:to_i)
ab = (N-1).times.map{gets.split.map(&:to_i)}
px = Q.times.map{gets.split.map(&:to_i)}

count = Array.new(N+1,0)

px.map{|x|
    count[x[0]] += x[1]
}

p ab
p px
p count

ab.map{|x|
    count[x[1]] += count[x[0]]
}

puts count[1..N].join(" ")