Scanf.scanf "%d" @@ fun n ->
  let sps = Array.init n @@ fun i -> Scanf.scanf " %s %d" @@ fun s p -> i + 1, s, p in
  let cmp (i, s, p) (j, s1, p1) = if s < s1 then -1 else if s > s1 then 1 else p1 - p in
  Array.sort cmp sps;
  Array.iter (fun (i, s, p) -> Printf.printf "%d\n" i) sps