fun main(args:Array<String>) {
    val shopCount = readLine()!!.toInt()
    (1..shopCount).map { num-> readLine()!!.split(" ").let { item(num, it[0], it[1].toInt()) } }.sortedBy { it.price * -1 }.sortedBy { it.city }.forEach { println(it.id) }
}

class item(val id:Int, val city:String, val price:Int)
