let n = Scanf.scanf " %d" (+) 0
let sps = Array.init n @@ fun i -> Scanf.scanf " %s %d" @@ fun a b -> a, -b, i + 1
let _ = Array.sort compare sps; Array.iter (fun (_, _, i) -> Printf.printf "%d\n" i) sps