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