import java.util.*
import kotlin.comparisons.compareBy

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    (1..n).map { Restaurant(index = it, city = sc.next(), score = sc.nextInt()) }
            .sortedWith(compareBy({ it.city }, { -it.score }))
            .forEach { println(it.index) }
}

data class Restaurant(val index: Int, val city: String, val score: Int)
