while True: try: s1 = input().strip() s2 = input().strip() except EOFError: break if len(s1) > len(s2): s1, s2 = s2, s1 ret = '' for start in range(len(s1)): for end in range(start+1, len(s1)+1): sub = s1[start:end] if len(sub) > len(ret) and sub in s2: ret = sub print(ret)