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:
import sys
def foo1(s, t):
    while t in s:
	ind = s.find(t)
        s = s[:ind] + s[ind + 1:]
    return s
def foo2(s, t):
    while t in s:
        ind = s.find(t)
        l = ind
        while l > 0 and s[l - 1] == s[l]:
            l -= 1
        r = ind + len(t) - 1
        while r + 1 < len(s) and s[r + 1] == s[r]:
            r += 1
        if ind - l >= r - (ind + len(t) - 1):
            s = s[:ind + len(t) - 1] + s[r + 1:]
        else:
            s = s[:l] + s[ind + 1:]
    return s
def foo3(s, t):
    while t in s:
        ind = s.find(t)
        l = ind
        r = ind + len(t) -1
        if r + 1 < len(s) and s[r + 1] != s[r]:
            s = s[:r] + s[r + 1:]
        else:
            while t[l + 1 - ind] == t[l - ind]:
                l += 1
            while t[r - ind - len(t)] == t[r - ind - len(t) + 1] and r - ind - len(t) >=0:
                r -= 1
            s = s[:l + 1] + s[l + 1:r - 1] + s[r:]
    return s      
def chk(t):
    i = 0
    flag = 1
    while i < len(t) - 1:
        if t[i + 1] != t[i]:
            flag += 1
        i += 1
    return flag 
def foo(s, t, sel):
    if sel == 1:
        return foo1(s, t)
    if sel == 2:
        return foo2(s, t)
    if sel >= 3:
        return foo3(s, t)
def main():
    a = raw_input()
    b = raw_input()
    t = raw_input()
    res = ""
    sel = chk(t)
    rec = [["" for i in range(len(b) + 1)] for j in range(len(a) + 1)]
    for i in range(len(a)):
        for j in range(len(b)):
            if a[i] == b[j]:
                rec[i + 1][j + 1] = rec[i][j] + a[i]
                r = foo(rec[i + 1][j + 1], t, sel)
                if len(res) < len(r):
                    res = r
            else:
                if len(rec[i + 1][j]) > len(rec[i][j + 1]):
                    rec[i + 1][j + 1] = rec[i + 1][j]
                else:
                    rec[i + 1][j + 1] = rec[i][j + 1]
    if len(res) == 0:
        print 0
    else:
        print res
main()