let () =
    let main () =
        let n = Scanf.sscanf (read_line ()) "%d" (fun n -> n) in
        let arr = Array.init n (fun i -> Scanf.sscanf (read_line ()) "%s %d" (fun s p -> s, p, i + 1)) in
        Array.sort (fun (s1, p1, _) (s2, p2, _) -> compare (s1, -p1) (s2, -p2)) arr;
        Array.iter (fun (_, _, i) -> Printf.printf "%d\n" i) arr
    in
    main ()