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.util.Arrays;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Alexandr Azizyan
 */
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.nextLine();
        String s2 = in.nextLine();
        String virus = in.nextLine();

        int[] pf = new int[virus.length()];
        for (int i = 2; i < virus.length(); i++)
            for (int j = i - 1; j >= 1; j--)
                if (virus.substring(0, i).endsWith(virus.substring(0, j))) {
                    pf[i] = j;
                    break;
                }

        int[][][] dp = new int[s1.length() + 1][s2.length() + 1][virus.length()];
        int[][][] fix = new int[s1.length() + 1][s2.length() + 1][virus.length()];
        for (int[][] i : dp)
            for (int[] j : i)
                Arrays.fill(j, -1);
        dp[0][0][0] = 0;
        for (int i = 0; i <= s1.length(); i++)
            for (int j = 0; j <= s2.length(); j++)
                for (int k = 0; k < virus.length(); k++)
                    if (dp[i][j][k] >= 0) {
                        if (i + 1 <= s1.length() && dp[i + 1][j][k] < dp[i][j][k]) {
                            dp[i + 1][j][k] = dp[i][j][k];
                            fix[i + 1][j][k] = 1;
                        }
                        if (j + 1 <= s2.length() && dp[i][j + 1][k] < dp[i][j][k]) {
                            dp[i][j + 1][k] = dp[i][j][k];
                            fix[i][j + 1][k] = 2;
                        }
                        if (i + 1 <= s1.length() && j + 1 <= s2.length() && s1.charAt(i) == s2.charAt(j)) {
                            int nk = k;
                            while (1 < 2) {
                                if (s1.charAt(i) == virus.charAt(nk)) {
                                    nk++;
                                    break;
                                }
                                if (nk == 0)
                                    break;
                                nk = pf[nk];
                            }
                            if (nk < virus.length() && dp[i + 1][j + 1][nk] < dp[i][j][k] + 1) {
                                dp[i + 1][j + 1][nk] = dp[i][j][k] + 1;
                                fix[i + 1][j + 1][nk] = k + 3;
                            }
                        }
                    }

        int k = 0;
        for (int i = 0; i < virus.length(); i++)
            if (dp[s1.length()][s2.length()][i] > dp[s1.length()][s2.length()][k])
                k = i;

        if (dp[s1.length()][s2.length()][k] == 0) {
            out.println(0);
            return;
        }

        String ans = "";
        for (int i = s1.length(), j = s2.length(); i > 0 && j > 0; ) {
            if (fix[i][j][k] == 1)
                i--;
            else if (fix[i][j][k] == 2)
                j--;
            else {
                k = fix[i][j][k] - 3;
                i--;
                j--;
                ans = s1.charAt(i) + ans;
            }
        }
        out.println(ans);
    }
}