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

Solution:
import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskD {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
        String s1 = in.next();
        char[] c1 = s1.toCharArray();
        String s2 = in.next();
        char[] c2 = s2.toCharArray();
        String virus = in.next();
        int[][] next = new int[virus.length() + 1][128];
        int n = c1.length;
        int m = c2.length;

        int l = virus.length();
        for (int i = 0; i < l; ++i)
            for (char j = 'A'; j <= 'Z'; ++j) {
                if (j == virus.charAt(i)) next[i][j] = i + 1;
                else {
                    String suffix = virus.substring(0, i) + j;
                    for (int from = 0; from < suffix.length(); ++from) if(virus.startsWith(suffix.substring(from))) {
                        next[i][j] = suffix.length() - from;
                        break;
                    }
                }
            }
        int[][][] dp = new int[n + 1][m + 1][l + 1];
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < m; ++j)
                for (int k = 0; k < l; ++k) {
                    if (c1[i] == c2[j]) {
                        int nextState = next[k][c1[i]];
                        if (nextState != l)
                            dp[i + 1][j + 1][nextState] = Math.max(dp[i][j][k] + 1, dp[i + 1][j + 1][nextState]);
                    }
                    //else
                    dp[i + 1][j + 1][k] = Math.max(dp[i][j + 1][k], dp[i + 1][j + 1][k]);
                    dp[i + 1][j + 1][k] = Math.max(dp[i + 1][j][k], dp[i + 1][j + 1][k]);
            }

        StringBuffer ret = new StringBuffer("");
//        for (int i = n, j = m; i > 0 && j > 0;) {
//            if (c1[i - 1] == c2[j - 1]) {//dp[i][j] == dp[i - 1][j - 1] + 1) {
//                ret.append(c1[i - 1]);
//                --i; --j;
//            } else if (dp[i][j] == dp[i - 1][j]) {
//                --i;
//            } else if (dp[i][j] == dp[i][j - 1]) {
//                --j;
//            }
//        }
        int maxLen = 0;
        for (int i = 0, max = Integer.MIN_VALUE; i < virus.length(); ++i) {
            if (dp[n][m][i] > max) {max = dp[n][m][i]; maxLen = i;}
        }
        for (int i = n, j = m, curState = maxLen; i > 0 && j > 0;) {
            boolean find = false;
            if (c1[i - 1] == c2[j - 1]) {
                for (int k = 0; k < l; ++k) {
                    int nextState = next[k][c1[i - 1]];
                    if (curState == nextState && dp[i][j][curState] == dp[i - 1][j - 1][k] + 1) {
                        find = true;
                        ret.append(c1[i - 1]);
                        //out.println(ret);
                        --i; --j; curState = k;
                        break;
                    }
                }
            }
            if (!find && dp[i][j][curState] == dp[i - 1][j][curState]) {
                --i;
            } else if (!find && dp[i][j][curState] == dp[i][j - 1][curState]) {
                --j;
            }
        }
        if (ret.length() == 0) out.println(0);
        else out.println(ret.reverse());
    }
}