import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val restaurants = Array.fill(n)(readLine().split(" "))
    .map(list => (list(0), list(1).toInt))

  def solve() = {
    restaurants.zipWithIndex.sortBy { case ((name, score), _) => (name, -score) }.map(_._2 + 1).mkString("\n")
  }

  println(solve())

}

