a = input() b = input() ret = [] out = [] if len(a) > len(b): a, b = b, a left = right = 0 for right in range(1, len(a) + 1): while a[left:right] in b and right - 1 < len(a): ret.append(right - left) out.append(a[left:right]) right += 1 else: left += 1 pos = ret.index(max(ret)) print(out[pos])