import java.util.*

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val list = Array(N) { i ->
        val (S, P) = readLine()!!.split(" ")
        Triple(i, S, P.toInt())
    }
    val result = list.sortedArrayWith(Comparator { o1, o2 -> if (o1.second != o2.second) o1.second.compareTo(o2.second) else o2.third.compareTo(o1.third) })
    println(result.map { it.first + 1 }.joinToString("\n"))
}