var restaurants = [(Int, String, Int)]()
for i in 1...Int(readLine()!)! {
  let input = readLine()!.characters.split(" ").map{String($0)}
  restaurants += [(i, input[0], Int(input[1])!)]
}
restaurants.sortInPlace{
  if $0.1==$1.1 {
    return $0.2>$1.2
  }
  return $0.1<$1.1
}
for restaurant in restaurants {
  print(restaurant.0)
}