																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
_, a, c = Qs.shift
l.add(a)
r.add(-a)
Qs.each do |q, a, b|
  if q == 1
    c += b
    case
    when a < (m = l.pop)
      c += m - a
      r.add(-m)
      l.add(a)
      l.add(a)
    when (m = -r.top) < a
      c += a - m
      l.add(m)
      r.add(-a)
      r.add(-a)
    else
      l.add(a)
      r.add(-a)
    end
  else
    puts "#{l.top} #{c}"
  end
end