object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    val inputs = List.tabulate(N)(i => (i + 1, sc.next, sc.nextInt))
    sc.close()

    val sorted = inputs.sortBy{ case (_, x,y) => (x, -y) }
    sorted.foreach(p => println(p._1))
  }
}