private data class Rev(val name: String, val score: Int, val index:Int)

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    var data = mutableListOf<Rev>()
    for ( i in 0 until n) {
        val (name, score) = readLine()!!.split(" ")
        data.add(Rev(name, score.toInt(), i+1))
    }

    data.sortByDescending { it.score }
    data.sortBy { it.name }

    for (d in data) {
        println(d.index)
    }
}