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:
function fail(s){
	var n = s.length;
	for (var i = 1; i < n; ++i) {
		var j = F[i - 1];
		while (j > 0 && s[i] != s[j])
			j = F[j - 1];
		if (s[i] == s[j])  ++j;
		F[i] = j;
	}
}
function init(){
	dp = new Array(105);
	for(var i = 0; i < 105; i++) {
		dp[i] = new Array(105);
		for (var j = 0; j < 105; j++) {
			dp[i][j] = new Array(105);
			for (var k = 0; k < 105; k++) 
				dp[i][j][k] = {x: -1, y: ""};
		}
	}
	F = new Array(105);
	for(var i = 0; i < 105; i++) F[i] = 0;
}
function clone(o){
	return JSON.parse(JSON.stringify(o));
}
function lcs(i, j, k){
	if(i >= n || j >= m) return {x: 0, y: ""};
	if(dp[i][j][k].x != -1) return clone(dp[i][j][k]);
	//console.log(i + " "+ j  + " " +k);
	var skipLeft = clone(lcs(i + 1, j, k)) , skipRight = clone(lcs(i, j + 1, k)), equal = {x:-1, y:""};
	if(s[i] == t[j]){
		var tempK = k;
		//console.log(i + " " + j + " "+ k + " HENA1");
		if(s[i] == v[k]){
			//console.log("HENA");
			tempK++;
		}
		else if(k > 0){
			//console.log("YALLAA " + tempK + " " + F[tempK - 1]);
			tempK = F[tempK - 1];
			while(tempK > 0 && v[tempK] != s[i]) tempK = F[tempK - 1];
			if(v[tempK] == s[i]) tempK++;
		}
		if(tempK != vv){
			equal = clone(lcs(i + 1, j + 1, tempK));
			equal.x++;
			//console.log(s[i] + " " + equal.y);
			equal.y = s[i] + equal.y;
			//console.log(equal.y);
		}
		//else console.log("HeeeeeeeeEEH");
	}
	var sols = [skipLeft, skipRight, equal]; sols.sort(function(a, b){return parseInt(b.x) - parseInt(a . x);});
	var sol = sols[0];
	//return sol;
	return (dp[i][j][k] = clone(sol));	
}
var s = readline();
var t = readline();
var v = readline();
var n = s.length, m = t.length, vv = v.length, dp, F;
init();fail(v);
var soli = lcs(0, 0, 0);
if(soli.x == 0){
	print("0");
}
else print(soli.y);