import java.io.PrintWriter
import java.util.PriorityQueue
import java.util.Comparator

val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    func()
    pw.flush()
}
fun println(value: Any) { pw.println(value) }

fun func() {
    var Q = nextInt()
    var q1 = PriorityQueue<Long>(Q, Comparator { a, b ->  b.compareTo(a) })
    var q2 = PriorityQueue<Long>(Q, Comparator { a, b ->  a.compareTo(b) })
    var s1 = 0L; var s2 = 0L; var B = 0L
    for (n in 0 until Q) {
        var t = listOfLong()
        if (t[0] == 1L) {
            var a = t[1]; var b = t[2]
            B += b
            q1.add(a); q2.add(a)
            var l = q1.peek(); var r = q2.peek()
            if (l > r) {
                q1.poll(); q1.add(r)
                q2.poll(); q2.add(l)
                s1 += r
                s2 += l
            } else {
                s1 += l
                s2 += r
            }
        } else {
            var a = q1.peek()
            println("${a} ${s2 - s1 + B}")
        }
    }
}

fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { it.toLong() }
