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
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

public class LuckyCommonSubsequence {
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		String s1 = br.readLine();
		String s2 = br.readLine();
		String virus = br.readLine();

		String[][][] dp = new String[s1.length()][s2.length()][virus.length()];

		for (int i = 0; i < dp.length; i++) {
			for (int j = 0; j < dp[0].length; j++) {
				Arrays.fill(dp[i][j], "-");
			}
		}

		int N = virus.length();
		int[] kmp = new int[N];
		computeLPSArray(virus, N, kmp);

		String ans = solve(0, 0, 0, dp, virus, s1, s2, kmp);
		System.out.println(ans.equals("") ? 0 : ans);

		bw.close();
	}

	static String solve(int i, int j, int vir, String[][][] dp, String virus, String s1, String s2, int[] kmp) {
		if (vir == virus.length())
			return "0";
		if (i == dp.length || j == dp[0].length)
			return "";

		if (!dp[i][j][vir].equals("-"))
			return dp[i][j][vir];

		String op0 = "";
		String op4 = "";
		String op5 = "";

		if (s1.charAt(i) == s2.charAt(j)) {
			char car = s1.charAt(i);
			if (car == virus.charAt(vir)) {
				op0 = solve(i + 1, j + 1, vir + 1, dp, virus, s1, s2, kmp);
				if (op0.equals("0")) {
					op0 = "";
				} else {
					op0 = car + op0;
				}
			} else {
				if (vir > 0 && car == virus.charAt(kmp[vir-1])) {
					op5 = solve(i + 1, j + 1, kmp[vir-1] + 1, dp, virus, s1, s2, kmp);
					if (op5.equals("0")) {
						op5 = "";
					} else {
						op5 = car + op5;
					}
//				} else if(car == virus.charAt(0)){
//					op5 = s1.charAt(i) + solve(i + 1, j + 1, 1, dp, virus, s1, s2, kmp);
					
				} else {
					op5 = s1.charAt(i) + solve(i + 1, j + 1, 0, dp, virus, s1, s2, kmp);
				}
			}

		}
		String op1 = solve(i + 1, j, vir, dp, virus, s1, s2, kmp);
		String op2 = solve(i, j + 1, vir, dp, virus, s1, s2, kmp);
		String op3 = solve(i + 1, j + 1, vir, dp, virus, s1, s2, kmp);
		ArrayList<String> options = new ArrayList<String>();
		options.add(op0);
		options.add(op1);
		options.add(op2);
		options.add(op3);
		options.add(op4);
		options.add(op5);

		long max = Math.max(op0.length(), Math.max(op1.length(), Math.max(op2.length(), op3.length())));
		max = Math.max(max, op4.length());
		max = Math.max(max, op5.length());
		for (String string : options) {
			if (string.length() == max) {
				return dp[i][j][vir] = string;
			}
		}
		return dp[i][j][vir] = op0;
	}

	static void computeLPSArray(String pat, int M, int lps[]) {
		// length of the previous longest prefix suffix
		int len = 0;
		int i = 1;
		lps[0] = 0; // lps[0] is always 0

		// the loop calculates lps[i] for i = 1 to M-1
		while (i < M) {
			if (pat.charAt(i) == pat.charAt(len)) {
				len++;
				lps[i] = len;
				i++;
			} else // (pat[i] != pat[len])
			{
				// This is tricky. Consider the example.
				// AAACAAAA and i = 7. The idea is similar
				// to search step.
				if (len != 0) {
					len = lps[len - 1];

					// Also, note that we do not increment
					// i here
				} else // if (len == 0)
				{
					lps[i] = len;
					i++;
				}
			}
		}
	}

}