q = gets.chomp.to_i

left = []
right = []
min = 0

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