f = '(AABBAA)/' T1, T2 = [input().strip() for _ in range(2)] print(f.replace('AA', T1).replace('BB', T2))