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])!)]
}
arr = arr.sort({$0.1==$1.1 ? $0.2>$1.2 : $0.1<$1.1})
for element in arr {
  print(element.0)
}