import java.util.*
fun toS(x: Int): String {
    val s = x.toString()
    if (s.length == 1) {
        return "00" + s
    } else if (s.length == 2) {
        return "0" + s
    }
    return s
}

class Shop(name: String, point: Int, number: Int) {
    val dict = name + "               " + toS(100-point)
    val number = number
}

fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val a: MutableList<Shop> = mutableListOf()
    for (i in 1..n) {
        a.add(Shop(cin.next(), cin.nextInt(), i))
    } 
    val a_s = a.sortedBy { it.dict }
    for (i in 0..n-1) {
        println(a_s[i].number)
    }
}