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