def is_subsequence(s, t): it = iter(t) return all(c in it for c in s) S = input().strip() T = input().strip() if not S: print(-1) exit() # Find the lexicographically smallest character in S min_char = min(S) # Check if this character exists in T if min_char not in T: print(min_char) exit() # Check if the entire S is a subsequence of T if is_subsequence(S, T): print(-1) else: print(S)