fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = (0 until n).map {
        val (s, p) = readLine()!!.split(' ')
        Triple(it + 1, s, p.toInt())
    }
    xs.sortedByDescending { it.third }.sortedBy { it.second }.forEach {
        println(it.first)
    }
}