fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var sp = mutableListOf<Triple<String,Int,Int>>()

    for (i in 1 .. n){
        var tmp = readLine()!!.split(" ")
        sp.add(Triple(tmp[0], tmp[1].toInt(), i))
    }


    for (i in sp.sortedBy { -it.second }.sortedBy { it.first }) println(i.third)
}