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 f (s, p, i) (s2, p2, i2) = if s = s2 then compare p2 p else compare s s2
let _ = Array.sort f sps; Array.iter (fun (_, _, i) -> Printf.printf "%d\n" i) sps