q = gets.chomp.to_i

left = []
right = []
min = 0

q.times do |count|
  query = gets.chomp
  case query[0]
  when '1'
    _, a, b = query.split.map(&:to_i)
    min += b
    if count == 0
      left[0] = a
    elsif count.even?
      if a < left[-1]
        min += left[-1] - a
        pos = left.bsearch_index{ |x| x > a } || -1
        left.insert(pos, a)
      elsif left[-1] <= a && a <= right[0]
        left.push(a)
      else
        min += a - right[0]
        left.push(right.shift)
        pos = right.bsearch_index{ |x| x > a } || -1
        right.insert(pos, a)
      end
    elsif count.odd?
      if a < left[-1]
        min += left[-1] - a
        right.unshift(left.pop)
        pos = left.bsearch_index{ |x| x > a } || -1
        left.insert(pos, a)
      else
        min += a - left[-1]
        pos = right.bsearch_index{ |x| x > a } || -1
        right.insert(pos, a)
      end
    end
  when '2'
    printf("%d %d\n", left[-1], min)
  end
end
