type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]

let util = ABC(stdin)

let N = util.Scan1 int
let xs = util.ScanVecV N (fun x -> x.Split() |> fun a -> a.[0], (int a.[1]))

xs
|> Array.indexed
|> Array.sortWith (fun (_,(a1,b1)) -> fun (_,(a2,b2)) ->
    match compare a1 a2 with
    | 0 -> compare b2 b1 // desc on score
    | n -> n
    )
|> Array.map (fst >> ((+) 1))
|> Array.iter (printfn "%d")