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


public class LuckySubSequenc {

	public static void main(String args[]){
		StringBuilder out = new StringBuilder();
		InputReader in = new InputReader(System.in);
		hi s = new hi();
		s.answer(in,out);
		System.out.print(out);
		
	}
}
class hi{
	static char[] v;
	static char[] c1;
	static char[] c2;
	static int m;
	static int len1;
	static int len2;
	static int pre[] = new int[101];
	static int dp[][][] = new int[101][101][101];
	static StringBuilder o ;
	static void answer(InputReader in, StringBuilder out){
		o =out;
		c1 = in.next().toCharArray();
		c2 = in.next().toCharArray();
		v = in.next().toCharArray();
		len1 = c1.length;
		len2 = c2.length;
		for(int i=0;i<101;i++) for(int j=0;j<101;j++) for (int k = 0; k <101; k++) dp[i][j][k] = -1;
		preprocces();
int soln=solve(0,0,0);
		 trace(0,0,0);
		if(soln<=0) out.append("0");

	}

	public static void trace(int i,int j, int k){
		if(k==v.length) return;

		if(i==len1||j==len2) return ;

		if(c1[i]==c2[j]){


			int k2 =k;
			while(k2>0&&c1[i]!=v[k2]) k2 = pre[k2-1];
			if(c1[i]==v[k2]) k2++;
			int sol1 = 1+solve(i+1,j+1,k2);
			int sol2 = solve(i+1,j,k);
			int sol3 = solve(i,j+1,k);
			if(dp[i][j][k]==sol1){
				o.append(c1[i]);
				trace(i+1,j+1,k2);
				return;
			}
			if(dp[i][j][k]==sol2){

				trace(i+1,j,k);
				return;
			}
			if(dp[i][j][k]==sol3){

				trace(i,j+1,k);
				return;
			}




		}
		if(dp[i][j][k]==solve(i+1,j,k)){
			trace(i+1,j,k);
			return;
		}
if(dp[i][j][k]==solve(i,j+1,k)){
	trace(i,j+1,k);
	return;
}

	}


	public static int solve(int i,int j, int k){
		if(k==v.length) return -20000000;

		if(i==len1||j==len2) return 0;
		if(dp[i][j][k]!=-1) return dp[i][j][k];
		if(c1[i]==c2[j]){


			int k2 =k;
			while(k2>0&&c1[i]!=v[k2]) k2 = pre[k2-1];
			if(c1[i]==v[k2]) k2++;
			int sol1 = 1+solve(i+1,j+1,k2);
			int sol2 = solve(i+1,j,k);
			int sol3 = solve(i,j+1,k);
			return dp[i][j][k] =Math.max(sol1,Math.max(sol1,sol2));




		}
		return dp[i][j][k] =Math.max(solve(i+1,j,k),solve(i,j+1,k));


	}
	public static void preprocces(){
		pre[0] = 0;
		m = v.length;
		int k =0;
		for(int i=1;i<m;i++){
			while(k>0&&v[i]!=v[k]) k = pre[k-1];
			if(v[i]==v[k]) k++;
			pre[i] = k;

		}
	}

}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public int j() {
		return Integer.parseInt(next());
	}

}