open System
let N = int(Console.ReadLine())
let SP = [|for i in 1.. N do
  let tmp = (Console.ReadLine().Split(' '))
  yield (tmp.[0], - int (tmp.[1]), i)
|]

let sorted = Array.sort SP
let f (p : string * int * int) =
    let _, _, i = p
    Console.WriteLine i
Array.iter f sorted