import java.util.*

data class Data(val s: String, val p: Int, val i: Int) : Comparable<Data> {
    override fun compareTo(other: Data): Int {
        val r = s.compareTo(other.s)
        if (r != 0) return r
        return other.p - p
    }
}

fun main(args: Array<String?>) {
    val scanner = Scanner(System.`in`)

    val n = scanner.nextInt()
    val array = ArrayList<Data>(n)
    for (i in 1..n) {
        val s = scanner.next()
        val p = scanner.nextInt()
        array.add(Data(s, p, i))
    }
    array.sort()
    array.forEach {
        println(it.i)
    }
}
