import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val list = ArrayList<Restaurant>()
    repeat(n) {
        val line = readLine()!!.split(" ")
        list.add(Restaurant(it + 1, line[0], line[1].toInt()))
    }
    list.sort()
    list.forEach { println(it.number) }
}

data class Restaurant(val number: Int, val city: String, val score: Int) : Comparable<Restaurant> {
    override fun compareTo(other: Restaurant): Int {
        if (this.city != other.city) {
            return this.city.compareTo(other.city)
        }
        return -this.score.compareTo(other.score)
    }
}
