Problem: In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.

You are given two strings s1, s2 and another string called virus. Your task is to find the longest common subsequence of s1 and s2, such that it doesn't contain virus as a substring.

Input

The input contains three strings in three separate lines: s1, s2 and virus (1 ≤ |s1|, |s2|, |virus| ≤ 100). Each string consists only of uppercase English letters.

Output

Output the longest common subsequence of s1 and s2 without virus as a substring. If there are multiple answers, any of them will be accepted. 

If there is no valid common subsequence, output 0.

Examples

Input

AJKEQSLOBSROFGZ
OVGURWZLWVLUXTH
OZ


Output

ORZ


Input

AA
A
A


Output

0

Solution (in PYTHON3):

Solution:
s = input()
t = input()
u = input()

memos = {}
def solve(a, b, c):
    if c == len(u):
        return 0
    if a == len(s) or b == len(t):
        return ''
    if (a, b, c) in memos:
        return memos[(a, b, c)]

    me = s[a]

    r = solve(a + 1, b, c)
    try:
        idx = t[b:].index(me)

        curr = u[:c] + me
        for i in range(c + 2):
            if curr[i:] == u[:(c + 1 - i)]:
                tr = solve(a + 1, b + idx + 1, c + 1 - i)
                if tr == 0:
                    r2 = 0
                else:
                    r2 = me + tr
                break

        if r2 == 0 or len(r) > len(r2):
            k = r
        else:
            k = r2
    except ValueError:
        k = r

    memos[(a, b, c)] = k
    return k

# com = solve(0, 0)
# 
# memos2 = {}
# 
# def solve2(a, b):
#     if b == len(u):
#         return 0
#     if a == len(com):
#         return ''
#     if (a, b) in memos2:
#         return memos2[(a, b)]
# 
#     me = com[a]
#     r2 = solve2(a + 1, b)
# 
#     curr = u[:b] + me
#     for i in range(b + 2):
#         if curr[i:] == u[:(b + 1 - i)]:
#             t = solve2(a + 1, b + 1 - i)
#             if t == 0:
#                 r = 0
#             else:
#                 r = me + t
#             break
# 
#     if r != 0 and len(r) > len(r2):
#         k = r
#     else:
#         k = r2
# 
#     memos2[(a, b)] = k
#     return k

aaa = solve(0, 0, 0)
if aaa == '':
    print(0)
else:
    print(aaa)