import java.io.PrintWriter
val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    func()
    pw.flush()
}
fun println(value: Any) { pw.println(value) }

data class Restrant(val city: String, val point: Int, val index: Int): Comparable<Restrant> {
    override operator fun compareTo(other: Restrant): Int =
            when {
                this.city != other.city -> this.city.compareTo(other.city)
                this.point != other.point -> other.point - this.point
                else -> 0
            }
}

fun func() {
    val N = nextInt()
    val A: MutableList<Restrant> = arrayListOf()
    for (n in 0 until N) {
        val (s, p) = listOfString();
        A.add(Restrant(s, p.toInt(), n + 1))
    }
    A.sort()
    for (n in 0 until N) {
        println(A[n].index)
    }

}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
