Scanf.scanf "%s" (fun s ->
    let n = String.length s in
    let module S = Set.Make (struct type t = char let compare = compare end) in
    let rec loop i set =
        if i = 26 then set else loop (i + 1) (S.add (char_of_int (i + 97)) set)
    in
    let set = loop 0 S.empty in
    if n < 26 then (
        let rec loop i set =
            if i = n then Printf.printf "%s%c\n" s (S.min_elt set)
            else loop (i + 1) (S.remove s.[i] set)
        in
        loop 0 set
    ) else (
        let check s =
            let n = String.length s in
            let rec loop i set =
                if i = n then true else
                    if S.mem s.[i] set then false else
                        loop (i + 1) (S.add s.[i] set)
            in
            loop 0 S.empty
        in
        let rec loop len prefix cur =
            if cur = 26 then (
                if len = 0 then print_endline "-1" else
                    loop (len - 1) (String.sub prefix 0 (len - 1)) (int_of_char s.[len - 1] - 97 + 1)
            ) else (
                let s = Printf.sprintf "%s%c" prefix (char_of_int (cur + 97)) in
                if check s then print_endline s else
                    loop len prefix (cur + 1)
            )
        in
        loop n s 26
    )
)