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 PYTHON):

Solution:
a = raw_input()
b = raw_input()
virus = raw_input()


dp = [[[0] * (len(virus)) for _ in range(len(b) + 1)] for _ in range(len(a) + 1)]
dir = [[[(0, 0)] * (len(virus)) for j in range(len(b) + 1)] for i in range(len(a) + 1)]


pi = [0 for i in range(len(virus))]

k = 0
for i in range(1, len(virus)):
    while k > 0 and virus[i] != virus[k]:
        k = pi[k - 1]
    if virus[i] == virus[k]:
        k += 1
    pi[i] = k

fail = [[0 for _ in range(26)] for _ in range(len(virus))]
fail[0][ord(virus[0]) - ord('A')] = 1
for i in range(1, len(virus)):
    for j in range(ord('A'), ord('Z') + 1):
        if virus[i] == chr(j):
            fail[i][j - ord('A')] = i + 1
        else:
            fail[i][j - ord('A')] = fail[pi[i - 1]][j - ord('A')]


for i in range(len(a)):
    for j in range(len(b)):
        for k in range(len(virus)):
            if dp[i - 1][j][k] < dp[i][j - 1][k]:
                dp[i][j][k] = dp[i][j - 1][k]
                dir[i][j][k] = (0, -1)
            else:
                dp[i][j][k] = dp[i - 1][j][k]
                dir[i][j][k] = (-1, 0)

        if a[i] == b[j]:
            for k in range(len(virus)):
                if fail[k][ord(a[i]) - ord('A')] < len(virus) and dp[i][j][fail[k][ord(a[i]) - ord('A')]] < 1 + dp[i - 1][j - 1][k]:
                    dp[i][j][fail[k][ord(a[i]) - ord('A')]] = 1 + dp[i - 1][j - 1][k]
                    dir[i][j][fail[k][ord(a[i]) - ord('A')]] = (-1, -1, k)



m = max(dp[len(a) - 1][len(b) - 1][:])

s = ''
for k in range(len(virus)):
    if dp[len(a) - 1][len(b) - 1][k] == m:
        i = len(a) - 1
        j = len(b) - 1
        while i >= 0 and j >= 0:
            d = dir[i][j][k]
            if len(d) == 3:
                k = d[2]
                s = a[i] + s
            i += d[0]
            j += d[1]
        break

if len(s) > 0:
    print s
else:
    print 0