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


public class LuckyCommonSubsequence {
	static char s1[];
	static char s2[];
	static char[] virus;
	static StringBuilder dp[][][];
	static int dp_LCS[][][];
	static int INF = 1000000000;
	static int[] fail;
	static PrintWriter out;
	static StringBuilder ans;

	static int LCS(int i, int j, int prefixMatched) {
		if(prefixMatched >= virus.length) {
			return INF * -1;
		}
		if(i >= s1.length || j >= s2.length) {
			return 0;
		}
		if(dp_LCS[i][j][prefixMatched] != -1) {
			return dp_LCS[i][j][prefixMatched];
		}
		int res = -1;
		int res1 = -1;
		int prefixMatched2 = prefixMatched;
		while (prefixMatched2 >= 0 && s1[i] != virus[prefixMatched2])
			prefixMatched2 = fail[prefixMatched2];
		prefixMatched2++;
		res1 =  LCS(i+1,  j+1, prefixMatched);
		if(s1[i] == s2[j]) {
			res = LCS(i+1,  j+1, prefixMatched2) + 1;
		}
		return dp_LCS[i][j][prefixMatched] = Math.max(res1,
				Math.max(res, Math.max(LCS(i+1, j, prefixMatched), LCS(i, j+1, prefixMatched))));
	}
	static void LCSPrint(int i, int j, int prefixMatched) {
		if(i >= s1.length || j >= s2.length) {
			return;
		}
		int prefixMatched2 = prefixMatched;
		while (prefixMatched2 >= 0 && s1[i] != virus[prefixMatched2])
			prefixMatched2 = fail[prefixMatched2];
		prefixMatched2++;
		int optimal = LCS(i, j, prefixMatched);
		int sol1 = -1;
		if(s1[i] == s2[j]) {
			sol1 = LCS(i + 1, j + 1, prefixMatched2) + 1;
		}
		int sol4 = LCS(i+1, j+1, prefixMatched);
		int sol2 = LCS(i + 1, j, prefixMatched);
		int sol3 = LCS(i, j + 1, prefixMatched);
		if(optimal == sol4) {
			LCSPrint(i+1, j+1, prefixMatched);
		} else {
			if(optimal == sol2) {
				LCSPrint(i + 1, j, prefixMatched);
			} else {
				if(optimal == sol1) {
					ans.append(s1[i]);
					LCSPrint(i+1, j+1, prefixMatched2);
				}else {
					LCSPrint(i, j+1, prefixMatched);
				}
			}
		}
	}
	public static int[] FailFunction2(String s) {
		int n = s.length();
		int F[] = new int[n + 1];
		int i = 0, j = -1;
		F[i] = j;
		while (i < n) {
			while (j >= 0 && s.charAt(i) != s.charAt(j))
				j = F[j];
			i++;
			j++;
			F[i] = j;
		}
		return F;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		s1 = bf.readLine().toCharArray();
		s2 = bf.readLine().toCharArray();
		virus = bf.readLine().toCharArray();
		out = new PrintWriter(System.out);
		ans = new StringBuilder("");	
		dp_LCS = new int[s1.length+1][s2.length+1][virus.length+1];
		for(int i = 0; i< dp_LCS.length; i++) {
			for(int j = 0; j < dp_LCS[i].length; j++) {
				Arrays.fill(dp_LCS[i][j], -1);
			}
		}
		fail = FailFunction2(new String(virus));
		
		LCSPrint(0, 0, 0);
		
//		out.println(LCS(0, 0, 0));
		if(ans.toString().length() == 0){ 
			out.println('0');
		} else {
			out.println(ans.toString());
		}
		out.flush();
		out.close();
		
	}
}
