import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val n = s.nextInt
    val r = List.fill(n)(s.next , s.nextInt).zip(Stream from 1)
    r.sortBy(elm => (elm._1._1, -elm._1._2)).map(elm => elm._2).mkString("\n")
  }

  val tests = List(
    """6
      |khabarovsk 20
      |moscow 10
      |kazan 50
      |kazan 35
      |moscow 60
      |khabarovsk 40
      |""".stripMargin ->
      """3
        |4
        |6
        |1
        |5
        |2
        |""".stripMargin,
    """10
      |yakutsk 10
      |yakutsk 20
      |yakutsk 30
      |yakutsk 40
      |yakutsk 50
      |yakutsk 60
      |yakutsk 70
      |yakutsk 80
      |yakutsk 90
      |yakutsk 100""".stripMargin ->
    """10
      |9
      |8
      |7
      |6
      |5
      |4
      |3
      |2
      |1
    """.stripMargin
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}