n = gets.chomp.to_i
fs = []
as = []
bs = []

def f(x, as, bs, k, v = 0)
  return v if as.size == k
  v += (x - as[k]).abs + bs[k]
  f(x, as, bs, k + 1, v)
end

queries = []
n.times do |i|
  queries << gets.chomp.split(" ").map(&:to_i)
end
queries.each do |t, a, b|
  if t == 1
    as << a
    bs << b
  else
    x = as.sort_by {|v| v.abs}.first
    puts "#{x} #{f(x, as, bs, 0)}"
  end
end
