fun main(args: Array<String>) {
    var nsm = mapOf<Int, String>()
    var ism = mapOf<Int, Int>()
    for (i in 0 until readLine()!!.toInt()){
        var (x, y) = readLine()!!.split(" ")
        nsm = nsm.plus(y.toInt() to x)
        ism = ism.plus(y.toInt() to i)
    }
    var am = nsm.toList().sortedBy { it.first * -1 }.sortedBy { it.second }
    am.forEach {
        println(ism[it.first]!! + 1)
    }
}