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()
s1="/"+input()
virus=input()
d=dict()
aux=""
for i in range(len(virus)):
    for j in range(65,91):
        aux1=aux+chr(j)
        y=0
        for k in range(i+1):
            if aux1[0+k:i+1]==virus[0:i+1-k]:
                y=i+1-k
                break
        d.update({tuple([i,chr(j)]):y})
    aux+=virus[i]
n=len(s)
m=len(s1)
dp=[[["" for k in range(len(virus)+1)]for i in range(m+1)] for j in range(n+1)]
for i in range(1,n):
    for j in range(1,m):
        if s[i]==s1[j]:
            for k in range(len(virus)):
                y=d[k,s[i]]
                if y==len(virus):
                    continue
                if len(dp[i-1][j-1][k])+1>len(dp[i][j][y]) and len(dp[i-1][j-1][k])+1>len(dp[i][j-1][y]) and len(dp[i-1][j-1][k])+1>len(dp[i-1][j][y]):
                    dp[i][j][y]=dp[i-1][j-1][k]+s[i]
        for k in range(len(virus)):
            if len(dp[i-1][j][k])>len(dp[i][j-1][k]) and len(dp[i-1][j][k])>len(dp[i][j][k]):
                dp[i][j][k]=dp[i-1][j][k]
            elif len(dp[i][j-1][k])>=len(dp[i-1][j][k]) and len(dp[i][j-1][k])>len(dp[i][j][k]):
                dp[i][j][k]=dp[i][j-1][k]
ans=""
for i in dp[n-1][m-1][0:len(virus)]:
    if len(i)>len(ans):
        ans=i
if len(ans)>0:
    print(ans)
else:
    print(0)