object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val pw = new java.io.PrintWriter(System.out)
  val n = sc.nextInt()
  val s = for(i <- 0 until n) yield (i+1, sc.next(), sc.nextInt())
  val ans = s.toList.sortBy(x => (x._2, -x._3)).map(x => x._1).toList
  ans.foreach(pw.println(_))
  pw.flush()
}