fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val sList = (1..n).map { i -> Pair(i, readLine()!!.split(" ")) }
        .map { pair: Pair<Int, List<String>> -> Pair(pair.first, Pair(pair.second[0], pair.second[1].toInt())) }
        .toTypedArray()
    sList.sortByDescending { pair -> pair.second.second }
    sList.sortBy { pair -> pair.second.first }

    sList.forEach { println("${it.first}") }
}
