S=list(eval(input()))

N=len(S)

abc=list("abcdefghijklmnopqrstuvwxyz")

D={}

for a in abc:

    D[a]=0

idx={}

for i in range(26):

    idx[abc[i]]=i



for s in S:

    D[s]+=1

L=[]

for k,v in list(D.items()):

    if v==0:

        L.append(k)



L=sorted(L)

if len(L)==0:

    lis=[]

    for i in range(25,-1,-1):

        s=S[i]

        lis.append(s)

        if i!=0:

            if idx[s]>idx[S[i-1]]:

                break

    if len(lis)==26:

        print((-1))

        exit()



    lis=sorted(lis)

    for l in lis:

        if idx[S[i-1]]<idx[l]:

            add=l

            break

    ans="".join(S[:i-1])+add

    print(ans)



        

else:

    print(("".join(S)+L[0]))

#yzxwvutsrqponmlkjihgfedcba
S=list(eval(input()))

abc=list("abcdefghijklmnopqrstuvwxyz")

idx={}

for i in range(26):

    idx[abc[i]]=i

D=[0]*26

for s in S:

    D[idx[s]]+=1



if len(S)!=26:

    for i in range(26):

        if D[idx[abc[i]]]==0:

            ans="".join(S)+abc[i]

            break

        

else:

    ans=-1

    now=S[-1]

    for i in range(len(S)-1, 0,-1):

        if idx[S[i]]> idx[S[i-1]]:

            now=sorted(list(now))



            for j,n in enumerate(now):

                if idx[n]>idx[S[i-1]]:

                    pre=n

                    ans="".join(S[:i-1])+pre

                    print(ans)

                    exit()







        else:

            now=str(now)

            now+=S[i-1]



print(ans)
S = list(eval(input()))
N = len(S)
abc = list("abcdefghijklmnopqrstuvwxyz")
D = {}
for a in abc:
    D[a] = 0
idx = {}
for i in range(26):
    idx[abc[i]] = i
for s in S:
    D[s] += 1
L = []
for k, v in list(D.items()):
    if v == 0:
        L.append(k)
L = sorted(L)
if len(L) == 0:
    lis = []
    for i in range(25, -1, -1):
        s = S[i]
        lis.append(s)
        if i != 0:
            if idx[s] > idx[S[i - 1]]:
                break
    if len(lis) == 26:
        print((-1))
        exit()
    lis = sorted(lis)
    for l in lis:
        if idx[S[i - 1]] < idx[l]:
            add = l
            break
    ans = "".join(S[: i - 1]) + add
    print(ans)
else:
    print(("".join(S) + L[0]))
# yzxwvutsrqponmlkjihgfedcba

S = list(eval(input()))
abc = list("abcdefghijklmnopqrstuvwxyz")
idx = {}
for i in range(26):
    idx[abc[i]] = i
D = [0] * 26
for s in S:
    D[idx[s]] += 1
if len(S) != 26:
    for i in range(26):
        if D[idx[abc[i]]] == 0:
            ans = "".join(S) + abc[i]
            break
else:
    ans = -1
    now = S[-1]
    for i in range(len(S) - 1, 0, -1):
        if idx[S[i]] > idx[S[i - 1]]:
            now = sorted(list(now))
            for j, n in enumerate(now):
                if idx[n] > idx[S[i - 1]]:
                    pre = n
                    ans = "".join(S[: i - 1]) + pre
                    print(ans)
                    exit()
        else:
            now = str(now)
            now += S[i - 1]
print(ans)

-N = len(S) -D = {} -for a in abc: -    D[a] = 0 +D = [0] * 26 -    D[s] += 1 -L = [] -for k, v in list(D.items()): -    if v == 0: -        L.append(k) -L = sorted(L) -if len(L) == 0: -    lis = [] -    for i in range(25, -1, -1): -        s = S[i] -        lis.append(s) -        if i != 0: -            if idx[s] > idx[S[i - 1]]: -                break -    if len(lis) == 26: -        print((-1)) -        exit() -    lis = sorted(lis) -    for l in lis: -        if idx[S[i - 1]] < idx[l]: -            add = l +    D[idx[s]] += 1 +if len(S) != 26: +    for i in range(26): +        if D[idx[abc[i]]] == 0: +            ans = "".join(S) + abc[i] -    ans = "".join(S[: i - 1]) + add -    print(ans) -    print(("".join(S) + L[0])) -# yzxwvutsrqponmlkjihgfedcba +    ans = -1 +    now = S[-1] +    for i in range(len(S) - 1, 0, -1): +        if idx[S[i]] > idx[S[i - 1]]: +            now = sorted(list(now)) +            for j, n in enumerate(now): +                if idx[n] > idx[S[i - 1]]: +                    pre = n +                    ans = "".join(S[: i - 1]) + pre +                    print(ans) +                    exit() +        else: +            now = str(now) +            now += S[i - 1] +print(ans)