Q = gets.to_i.times.map{gets.split.map &:to_i}
x = [-1e9-1, 1e9+1]
y = 0
Q.each do |(_, a, b)|
  if a
    x.insert(x.bsearch_index{|i| a<=i}, a)
    y += b
  else
    i = x[x.size/2]
    puts [i, x[1...-1].inject(y){|s, v| s + (v-i).abs}]*" "
  end
end