fun main(args: Array<String>) {
    val scanner = System.`in`.bufferedReader()
    val n = scanner.readLine().toInt()
    val restaurants = Array(n) { i ->
        scanner.readLine().split(" ").let {
            Restaurant(i + 1, it[0], it[1].toInt())
        }
    }
    println(
        restaurants.sorted().joinToString("\n") {
            it.id.toString()
        }
    )
}

data class Restaurant(val id: Int, val name: String, val rank: Int) : Comparable<Restaurant> {
    override fun compareTo(other: Restaurant): Int {
        return when {
            this.name < other.name -> -1
            this.name == other.name -> when {
                this.rank == other.rank -> 0
                this.rank > other.rank -> -1
                else -> 1
            }
            else -> 1
        }
    }
}