open Printf
open Scanf

let read_int _ = scanf " %d " (fun x -> x)

let () =
  let n = read_int () in
  let sp = Array.init n (fun i -> scanf " %s %d " (fun x y -> x,y,(i+1))) in
  Array.fast_sort (fun (s1,p1,_) (s2,p2,_) -> if s1 <> s2 then compare s1 s2 else compare p2 p1) sp;
  Array.iter (fun (_,_,i) -> printf "%d\n" i) sp
