open System

[<EntryPoint>]
let main argv =

    let scoreCount = stdin.ReadLine() |> int

    let scores:(int*string*int) array = Array.create scoreCount (0,"", 0)

    for i = 0 to scoreCount - 1 do
        let inputs = stdin.ReadLine().Split(' ')

        scores.[i] <- (i+1, inputs.[0], int(inputs.[1]))

    for (i,s,p) in scores |> Array.sortBy(fun (i,s,p) -> s, -p) do
        printfn "%d" i

    0 // return an integer exit code
