import scala.annotation.tailrec
import scala.collection.mutable
import scala.io.StdIn._
object Main extends App{

  val q = readLine.trim.toInt
  var shiftUp = 0L
  var leftSum = 0L
  var rightSum = 0L
  val leftQueue = mutable.PriorityQueue[Int]()(Ordering.Int.reverse)
  val rightQueue = mutable.PriorityQueue[Int]()
  var center = 0
  var count = 0
  for (_ ← 0 until q) {
    readLine.trim.split(' ').map(_.toInt) match {
      case Array(2) if count == 0 ⇒
        println("0 0")
      case Array(2) if count % 2 == 0 ⇒
        println(s"$center ${shiftUp - leftSum + rightSum}")
      case Array(2) ⇒
        println(s"$center ${shiftUp - leftSum + rightSum}")
      case Array(1, a, b) if count % 2 == 1 ⇒
        count += 1
        shiftUp += b
        if (center < a) {
          leftQueue.enqueue(center)
          rightQueue.enqueue(a)
          leftSum += center
          rightSum += a
        }else {
          leftQueue.enqueue(a)
          rightQueue.enqueue(center)
          leftSum += a
          rightSum += center
        }
      case Array(1, a, b) ⇒
        count += 1
        shiftUp += b
        center = a
        if (leftQueue.nonEmpty && leftQueue.head > center) {
          leftSum += center
          leftQueue.enqueue(center)
          center = leftQueue.dequeue()
          leftSum -= center
        }else if (rightQueue.nonEmpty && rightQueue.head < center) {
          rightSum += center
          rightQueue.enqueue(center)
          center = rightQueue.dequeue()
          rightSum -= center
        }
      case _ ⇒ ???
    }
  }
}