let rec inp_loop : (unit -> 'a) -> int -> 'a list = fun inp_fun n ->
  if n = 0 then []
  else
    let x = inp_fun () in
    x :: inp_loop inp_fun (n - 1)

let () =
  let n = int_of_string (input_line stdin) in
  let l = inp_loop (fun () -> Scanf.sscanf (input_line stdin) "%s %d" (fun s p -> (s, p))) n in
  let l_i = List.mapi (fun i (s, p) -> (i + 1, s, p)) l in
  let l' = List.sort (fun (i1, s1, p1) (i2, s2, p2)->
               if s1 > s2 then 1
               else if s1 < s2 then -1
               else if p1 > p2 then -1
               else if p1 < p2 then 1
               else 0) l_i in
  List.iter (fun (i, s, p) ->
      print_int i;
      print_newline ()
    ) l'
