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.*;
import java.io.*;

public class Second {
	public static void main(String[] args) throws IOException {
		rd = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(System.out);
		for(int i=0; i<MAX_PREF.length; i++) Arrays.fill(MAX_PREF[i], -1);
		A = rd.readLine();
		B = rd.readLine();
		virus = rd.readLine();
		int best = 0;
		precalc();
		int I = -1, J = -1, LENG = -1;
		for(int i=0; i<A.length(); i++){
			for(int j=0; j<B.length(); j++){
				if(A.charAt(i)!=B.charAt(j)) continue;
				char ch = A.charAt(i);
				int current;
				if(ch==virus.charAt(0))
					current = find(i, j, 1);
				else
					current = find(i, j, 0);
				if(current>best){
					best = current;
					I = i;
					J = j;
					LENG = (ch==virus.charAt(0)? 1: 0);
				}
			}
		}
		if(I==-1){
			System.out.println(0);
			return;
		}
		constructWay(I, J, LENG);
	}
	
	static void constructWay(int up, int down, int leng){
		pw.print(A.charAt(up));
		if(find(up, down, leng)==1){
		//	pw.println(way[up][down][leng]);
		//	pw.flush();
			pw.println();
			pw.flush();
			return;
		}
		char ch = way[up][down][leng];
	//	pw.print(ch);
		int index = (int) (ch-'A');
		int nextUp = occ1[up][index], nextDown = occ2[down][index];
		constructWay(nextUp, nextDown, maxPref(leng, ch));
	}
	
	static int find(int up, int down, int leng){
		if(leng==virus.length()) return 0;
		if(A.charAt(up)!=B.charAt(down)) return 0;
		if(been[up][down][leng]) return dp[up][down][leng];
		int best = 1;
		for(char ch='A'; ch<='Z'; ch++){
			int index = (int) (ch-'A');
			int nextUp = occ1[up][index], nextDown = occ2[down][index];
			if(nextUp==-1 || nextDown==-1) continue;
			int current = 1 + find(nextUp, nextDown, maxPref(leng, ch));
			if(current>best){
				best = current;
				way[up][down][leng] = ch;
			}
//			best = Math.max(best, current);
		}
		been[up][down][leng] = true;
		return dp[up][down][leng] = best;
	}
	
	
	
	
	static boolean[][][] been = new boolean[101][101][27];
	
	static char[][][] way = new char[101][101][27];
	
	static int[][][] dp = new int[101][101][27];
	
	static void precalc(){
		for(int i=0; i<A.length(); i++){
			for(int c=0; c<26; c++){
				char ch = (char) ('A'+c);
				int found = -1;
				for(int x=i+1; x<A.length(); x++){
					if(A.charAt(x)==ch){
						found = x;
						break;
					}
				}
				occ1[i][c] = found;
			}
		}
		for(int i=0; i<B.length(); i++){
			for(int c=0; c<26; c++){
				char ch = (char) ('A'+c);
				int found = -1;
				for(int x=i+1; x<B.length(); x++){
					if(B.charAt(x)==ch){
						found = x;
						break;
					}
				}
				occ2[i][c] = found;
			}
		}
	}
	
	static int maxPref(int prefLength, char ch){
		int ind = (int) (ch-'A');
		if(MAX_PREF[prefLength][ind]!=-1) return MAX_PREF[prefLength][ind];
		String S = prefLength==0? "": virus.substring(0, prefLength);
		S += ch;
		for(int i=0; i<S.length(); i++){
			if(S.length()-i>virus.length())
			System.out.println(S.substring(i)+" "+virus.substring(0, S.length()-i));
			if(S.substring(i).equals(virus.substring(0, S.length()-i))) return MAX_PREF[prefLength][ind] = S.length()-i;
		}
		return MAX_PREF[prefLength][ind] = 0;
	}
	
	static int[][] MAX_PREF = new int[101][27];
	
	static int[][] occ1 = new int[101][27], occ2 = new int[101][27];
	
	static String A, B, virus;
	
	static BufferedReader rd;
	static PrintWriter pw;
	static StringTokenizer st;
	
}