object Main {
  import java.io.{BufferedReader, InputStream, InputStreamReader}
  import java.util.StringTokenizer
  import scala.reflect.ClassTag

  def main(args: Array[String]): Unit = {
    val out = new java.io.PrintWriter(System.out)
    new Main(out, new InputReader(System.in)).solve()
    out.flush()
  }

  private val oj = System.getenv("ATCODER_DEBUG") == null
  def DEBUG(f: => Unit): Unit = {
    if (!oj){ f }
  }
  def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) "1" else "0").mkString) }
  def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(" ")) }
  def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(" ")) }
  def debugDim(m: Array[Array[Long]]): Unit = if (!oj){
    REP(m.length) { i =>
      debug(m(i))
    }
  }
  def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){
    REP(m(0).length) { j =>
      REP(m.length) { i =>
        System.err.print(m(i)(j))
        System.err.print(" ")
      }
      System.err.println()
    }
  }
  def debug(s: => String): Unit = DEBUG {
    System.err.println(s)
  }
  def debugL(num: => Long): Unit = DEBUG {
    System.err.println(num)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = Integer.parseInt(next())
    def nextLong(): Long = java.lang.Long.parseLong(next())
    def nextChar(): Char = next().charAt(0)

    def ni(): Int = nextInt()
    def nl(): Long = nextLong()
    def nc(): Char = nextChar()
    def ns(): String = next()
    def ns(n: Int): Array[Char] = ns().toCharArray
    def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
    def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
      val A1, A2 = Array.ofDim[Int](n)
      REP(n) { i =>
        A1(i) = ni() + offset
        A2(i) = ni() + offset
      }
      (A1, A2)
    }
    def nm(n: Int, m: Int): Array[Array[Int]] = {
      val A = Array.ofDim[Int](n, m)
      REP(n) { i =>
        REP(m) { j =>
          A(i)(j) = ni()
        }
      }
      A
    }
    def nal(n: Int): Array[Long] = map(n)(_ => nl())
    def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  }

  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }
  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {
    REP(to - from + 1, from) { i =>
      f(i)
    }
  }
  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }
  def cumSum(as: Array[Int]): Array[Long] = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

case class Query(tpe: Int, a: Int, b: Int)

class BIT(n: Int, zero: Long)(f: (Long, Long) => Long) {
  def this(n: Int) = this(n, 0)(_ + _)

  private val N = {
    val a = Integer.highestOneBit(n)
    if (a == n) a else a << 1
  }
  private val bit = if (zero != 0) Array.fill[Long](N + 1)(zero) else Array.ofDim[Long](N + 1)

  /**
    * 1 index
    * addとindex違うよ
    * cumsumなんかといっしょ
    */
  def sum(i: Int): Long = {
    assert(i <= n)
    var x = i
    var s: Long = 0
    while(x > 0) {
      s = f(s, bit(x))
      x -= x & -x
    }
    s
  }

  /**
    * 0 index
    */
  def add(i: Int, a: Long): Unit = {
    assert(i < n)
    var x = i + 1
    while(x <= N) {
      bit(x) = f(bit(x), a)
      x += x & -x
    }
  }

  def sumAll: Long = sum(n)

  /**
    * [l, r)
    */
  def query(l: Int, r: Int)(sub: (Long, Long) => Long): Long = {
    assert(r > l)
    sub(sum(r), sum(l))
  }
}

class Main(out: java.io.PrintWriter, sc: Main.InputReader) {
  import sc._
  import Main._
  import java.util.Arrays.sort

  import scala.collection.mutable
  import math.{abs, max, min}
  import mutable.ArrayBuffer

  // toIntとか+7とかするならvalにしろ
  @inline private def MOD = 1000000007

  // todo debug
  val Inf = -10

  def solve(): Unit = {
    import java.util
    import java.util.Collections
    val Q = ni()
    val queries = Array.ofDim[Query](Q)
    val nums = new util.ArrayList[Integer]()

    REP(Q) { i =>
      val tpe = ni()
      queries(i) = tpe match {
        case 1 =>
          val a, b = ni()
          nums.add(a)
          Query(tpe, a, b)

        case 2 =>
          Query(tpe, 0, 0)
      }
    }
    nums.add(Inf)
    Collections.sort(nums)

    var p = 0
    val zip = mutable.HashMap[Int, Int]()
    REP(nums.size()) { i =>
      val a = nums.get(i)
      if (!zip.contains(a)) {
        zip.put(a, p)
        p += 1
      }
    }

    val x0 = new BIT(nums.size(), 0)(_ + _)
    val x1 = new BIT(nums.size(), 0)(_ + _)

    def f(id: Int): Long = {
      val x = nums.get(id)
      x1.sum(id + 1) * x + x0.sum(id + 1)
    }

//    def test(): Unit = {
//      REP(nums.size()) { i =>
//        val x = nums.get(i)
//        val id = zip(x)
//        val y = x1.sum(id + 1) * x + x0.sum(id + 1)
//        debug(s"x:$x y:$y")
//      }
//    }

    def test(id: Int): Boolean = {
      f(id) <= f(id + 1)
    }

    val infId = zip(Inf)

    var sumB = 0L
    REP(Q) { i =>
      queries(i).tpe match {
        case 1 =>
          sumB += queries(i).b
          val a = queries(i).a

          // INFで傾きを-1に、f(a)=0になるように調整する
          x1.add(infId, -1)
          x0.add(infId, a)

          // x=aで 傾きを-1 => 1 に変更
          x1.add(zip(a), 2)
          x0.add(zip(a), -2 * a)

        case 2 =>
          val id = findMin(test, 0, nums.size() - 1)
          val x = nums.get(id)
          val y = f(id) + sumB
          out.println(s"$x $y")
      }
    }
  }

  def findMin(f: Int => Boolean, min: Int, max: Int): Int = {
    var l = min - 1
    var h = max
    while(h - l > 1) {
      val x = (h + l) / 2
      if (f(x)) h = x
      else l = x
    }
    h
  }
}