object Main extends App {
	val N = scala.io.StdIn.readInt
	val a = new Array[(String, Int, Int)](N)

	for(i<-0 until N){
		val Array(ta, tb) = scala.io.StdIn.readLine.split(" ")
		a(i) = (ta, tb.toInt, i+1)
	}

	val b = a.sortBy(x => (x._1, -x._2))
	
	for(x <- b){
		println(x._3)
	}

}