fun main(args: Array<String>?): Unit {
    val n = readLine()!!.trim().toInt()
    val queries = Array(n){time ->
        val query = readLine()!!.trim().split(' ').map(String::toInt)
        when(query.first()) {
            1 -> Query.Update(time, query[1], query[2])
            else -> Query.Evaluation(time)
        }
    }
    var updateCount = 0
    var allA = 0L
    var allB = 0L
    val sortedUpdate = queries.mapNotNull{it as? Query.Update}.sortedBy { it.a }
    val updateToRank = sortedUpdate.withIndex().associate { Pair(it.value.time, it.index) }
    val indices = IntBit(updateToRank.size)
    val sumValues = LongBit(updateToRank.size)
    for (query in queries) {
        when(query){
            is Query.Update -> {
                indices.add(updateToRank[query.time]!!, 1)
                sumValues.add(updateToRank[query.time]!!, query.a.toLong())
                ++updateCount
                allA += query.a
                allB += query.b
            }
            is Query.Evaluation -> {
                val mid = lowerBound(indices, (updateCount + 1) / 2)
                println(when(updateCount % 2){
                    0 -> "${sortedUpdate[mid].a} ${allA - sumValues[mid] * 2 + allB}"
                    1 -> "${sortedUpdate[mid].a} ${allA - sumValues[mid] * 2 + sortedUpdate[mid].a + allB}"
                    else -> TODO()
                })
            }
        }
    }
}
fun lowerBound(bit: IntBit, value: Int): Int {
    var left = 0
    var right = bit.size
    while(left < right) {
        val mid = (left + right) / 2
        if (bit[mid] < value) left = mid + 1
        else right = mid
    }
    return right
}
class IntBit(val size: Int) {
    private val array = IntArray(size){0}
    fun add(position: Int, value: Int): Unit {
        var pos = position
        while (pos < array.size) {
            array[pos] += value
            pos += pos.inv() and (pos + 1)
        }
    }
    operator fun get(position: Int): Int {
        var pos = position
        var result = 0
        while (pos >= 0) {
            result += array[pos]
            pos -= pos.inv() and (pos + 1)
        }
        return result
    }
}
class LongBit(val size: Int) {
    private val array = LongArray(size){0}
    fun add(position: Int, value: Long): Unit {
        var pos = position
        while (pos < array.size) {
            array[pos] += value
            pos += pos.inv() and (pos + 1)
        }
    }
    operator fun get(position: Int): Long {
        var pos = position
        var result = 0L
        while (pos >= 0) {
            result += array[pos]
            pos -= pos.inv() and (pos + 1)
        }
        return result
    }
}
sealed class Query {
    abstract val time: Int
    class Update(override val time: Int, val a: Int, val b: Int): Query()
    class Evaluation(override val time: Int): Query()
}