import scala.io.StdIn._
object Main extends App{


  val n = readLine.trim.toInt
  val reviews = Array.tabulate(n){i ⇒
    val Array(s, p) = readLine.trim.split(' ')
    (i, s, p.toInt)
  }.sortWith{(a, b) ⇒ if (a._2 == b._2) a._3 > b._3 else a._2 < b._2}

  for ((i, _, _) ← reviews) {
    println(i + 1)
  }
}