object Main {
  def main(args: Array[String]): Unit = {
    import java.util.Scanner
    val in = new Scanner(System.in)
    val n = in.nextInt()
    val list = List.fill(n)(in.next() -> (in.nextInt() * -1))
    val indexedList = for ((data, i) <- list.zipWithIndex) yield (i, data)
    val sortedList = indexedList.sortBy(_._2._2).sortBy(_._2._1)
    for (i <- (0 until n)) println(sortedList(i)._1 + 1)
    in.close()
  }
}