[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let n = read int
    let xs =
        List.map (fun _ -> reads id) [1..n]
        |> List.zip [1..n]
        |> List.map (fun (i, [s;p]) -> (s, int p, i))
    List.groupBy (fun (s,_,_) -> s) xs
    |> List.sortBy fst
    |> List.collect (snd >> List.sortByDescending (fun (_,p,_) -> p))
    |> List.iter (fun (_,_,i) -> printfn "%i" i)
    0