Qs = readlines.drop(1).map{|l| l.split.map(&:to_i)}

# class PQ
#   attr :s

#   def initialize
#     @q = [nil]
#     @s = 0
#   end

#   def b_up(i)
#     p = i / 2
#     return if i <= 1 || @q[p] >= @q[i]
#     @q[i], @q[p] = @q[p], @q[i]
#     b_up(p)
#   end

#   def add(e)
#     @q << e
#     @s += e
#     b_up(@q.size - 1)
#   end

#   def b_dn(i)
#     c = i * 2
#     return if c >= @q.size
#     c += 1 if c != @q.size - 1 && @q[c] < @q[c + 1]
#     return if @q[i] >= @q[c]
#     @q[i], @q[c] = @q[c], @q[i]
#     b_dn(c)
#   end

#   def pop
#     @q[1], @q[-1] = @q[-1], @q[1]
#     ret = @q.pop
#     @s -= ret
#     b_dn(1)
#     ret
#   end

#   def top
#     @q[1]
#   end
# end

# l, r = PQ.new, PQ.new
l, r = [], []
_, a, c = Qs.shift
l.push(a)
r.push(-a)
Qs.each do |q, a, b|
  if q == 1
    c += b
    case
    when a < (m = l.pop)
      c += m - a
      r.push(-m)
      l.push(a)
      l.push(a)
    when (m = -r.pop) < a
      c += a - m
      l.push(m)
      r.push(-a)
      r.push(-a)
    else
      l.push(a)
      r.push(-a)
    end
    l.sort!
    r.sort!
  else
    puts "#{l.last} #{c}"
  end
end