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

fun main(args: Array<String>) {
    abc000X()
}

fun abc000X() {
    var n = readLine()!!.toInt()
    var list = Array(n) { i ->
        readLine()!!.split(" ").let { Restaurant(i + 1, it[0], it[1].toInt()) }
    }

    var sortedList = list.sortedWith(compareBy({ it.name }, { it.score * -1 }))

    sortedList.forEach {
        println(it.index)
    }
}

class Restaurant(val index: Int, val name: String, val score: Int)