var restaurants = [(num: Int, city: String, score: Int)]()
for i in 1...Int(readLine()!)! {
  let input = readLine()!.characters.split(" ").map{String($0)}
  restaurants += [(num: i, city: input[0], score: Int(input[1])!)]
}
restaurants.sortInPlace{
  ($0.city == $1.city) ? (return $0.score > $1.score) : (return $0.city < $1.city)
}
for restaurant in restaurants {
  print(restaurant.num)
}