let () =
  let find_opt f t =
    let rec loop = function
      | [] -> None
      | x :: l -> if f x then Some x else loop l
    in
    loop t
  in

  let a = Scanf.scanf "%s\n" (fun a -> a) in
  let input_char_list = BatString.to_list a in
  let all_chars = ['a';'b';'c';'d';'e';'f';'g';'h';'i';'j';'k';'l';'m';'n';'o';'p';'q';'r';'s';'t';'u';'v';'w';'x';'y';'z';] in

  let res =
    if (String.length a < 26)
    then (
      let hoge input_chars all_chars =
        let rec aux l = match l with
          | [] -> []
          | hd :: tl ->
            (
              match (find_opt (fun x -> x = hd) input_chars) with
                Some x -> aux tl
              | None -> [hd]
            )
        in                                                                                                                                                                                                                                           aux all_chars
      in
      BatList.append input_char_list (hoge input_char_list all_chars) |> BatString.of_list
    )
    else (
      if (a = "zyxwvutsrqponmlkjihgfedcba")
      then ("-1")
      else (
        let rec fuga l top last = match l with
          | [] -> []
          | aa :: bb :: cc ->
            if ((BatChar.code last) < (BatChar.code bb))
            then
              fuga (bb :: cc) (List.append top [aa]) last
            else
              let c = List.find (fun x -> x > bb) (List.sort compare (List.append top [aa])) in

              BatList.append [c] (cc)
        in
        let last = List.hd (List.rev input_char_list) in
        fuga (List.rev input_char_list) [] last |>
        List.rev |>
        BatString.of_list
      )
    )
  in print_endline res


