import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(2*10**5+10) write = lambda x: sys.stdout.write(x+"\n") debug = lambda x: sys.stderr.write(x+"\n") writef = lambda x: print("{:.12f}".format(x)) l = [chr(v) for v in range(ord("a"), ord("z")+1)] def snx(s, target=None, reverse=False, loop=False): """文字列sの各要素について、cがi【以上】のインデックスで最初に現れる位置n[i][c] ない場合はNone loop=Trueのとき周回した先のインデックスまで求める """ if isinstance(s[0], str): oa = ord("a") s = [ord(c)-oa for c in s] if target is None: target = list(range(26)) d = {c:-1 for c in target} nx = [[-1]*len(s) for _ in range(len(target))] if not reverse: i = len(s)-1 for c in reversed(s): d[c] = i for j,t in enumerate(target): nx[j][i] = d[t] i -= 1 if loop: for i in range(len(s)): for j in range(len(target)): if nx[j][i]==-1: nx[j][i] = nx[j][0] else: i = 0 for c in s: d[c] = i for j,t in enumerate(target): nx[j][i] = d[t] i += 1 if loop: for i in range(len(s)): for j in range(len(target)): if nx[j][i]==-1: nx[j][i] = nx[j][-1] return nx s = input() t = input() n = len(s) m = len(t) l = [m] j = m-1 for i in range(n)[::-1]: c = s[i] while j>=0 and t[j]!=c: j -= 1 l.append(j) if j>=0: j -= 1 l = l[::-1] if l[0]>=0: ans = -1 else: nx = snx(s) tnx = snx(t) ans = [] i = 0 j = 0 done = 0 while 1: for c in range(26): if not nx[c][i]>=0: continue if j>=m or tnx[c][j]==-1: ans.append(c) done = 1 break elif l[nx[c][i]] < tnx[c][j]: ans.append(c) i = nx[c][i] + 1 j = tnx[c][j] + 1 break if done: break ans = "".join([chr(ord("a")+c) for c in ans]) print(ans)