import java.util.Scanner

object Main extends App{

  val sc = new Scanner(System.in)

  val n  = sc.nextInt
  val rs = Seq.fill(n)((sc.next, sc.nextInt))

  val rsSorted = rs.zipWithIndex.sortWith{ case ((ra,_), (rb,_)) =>
    if(ra._1.compareTo(rb._1) == 0) ra._2.compareTo(rb._2) > 0
    else ra._1.compareTo(rb._1) < 0
  }
  val res = rsSorted.map(_._2 + 1)

  res.foreach(println(_))
}