import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val s = mutableListOf<Triple<String, Int, Int>>()
    for(i in 1 .. n){
        val (a,b) = readLine()!!.split(" ")
        s.add(Triple(a, b.toInt(), i))
    }
    s.sortByDescending{it.second}
    s.sortBy{it.first}
    s.forEach{println(it.third)}
}
