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

public class luckyLCS{
	public static void main(String args[]){
		Scanner cin = new Scanner(System.in);
		String s1,s2,virus;
		s1 = cin.nextLine();
		s2 = cin.nextLine();
		virus = cin.nextLine();

		Solution sol = new Solution();
		//sol.solve(s1,s2,virus);
		String ans = sol.wrapper(s1,s2,virus);
		if(ans.length() == 0)
			System.out.println(0);
		else System.out.println(ans);
		return;
	}
}

class Solution{
	private String s1,s2,virus;
	int n1,n2,n3;
	String[][][] dp;
	int[] lps;

	public StringBuilder rec(int i,int j,int pos){
		if(i>=n1 || j >= n2 || pos >= n3)
			return new StringBuilder("");

		if(!dp[i][j][pos].equals("0"))
			return new StringBuilder(dp[i][j][pos]);

		StringBuilder ans1 = new StringBuilder("");
		StringBuilder ans2 = new StringBuilder("");

		if(s1.charAt(i) == s2.charAt(j)){
			if(s1.charAt(i) == virus.charAt(pos)){
				if(pos == n3-1){
					ans1 = rec(i+1,j+1,pos);
				}
				else{
					ans1 = rec(i+1,j+1,pos+1).append(s1.charAt(i));
					ans2 = rec(i+1,j+1,pos);
				}	
			}
			else{
				// if(pos != 0)
				// System.out.println(pos+" "+lps[pos-1]);
				if(pos == 0)
					ans1 = rec(i+1,j+1,0).append(s1.charAt(i));
				else{
					if(virus.charAt(lps[pos-1]) == s1.charAt(i)){
						//System.out.println("baal");
						ans1 = rec(i+1,j+1,lps[pos-1]+1).append(s1.charAt(i));
					}
					else ans1 = rec(i+1,j+1,0).append(s1.charAt(i));
				}
				ans2 = rec(i+1,j+1,pos);
			}
		}
		else{
			ans1 = rec(i,j+1,pos);
			ans2 = rec(i+1,j,pos);
		}
		if(ans1.length() > 	ans2.length()){
			dp[i][j][pos] = ans1.toString();
			return ans1;
		}
		else{
			dp[i][j][pos] = ans2.toString();
			return ans2;
		}
	}
	public void calculateLps(int[] lps,String virus){
		int n = virus.length();
		int i=1;
		int j=0;
		while(i < n){
			if(virus.charAt(i) == virus.charAt(j)){
				lps[i] = j+1;
				i++;
				j++;
			}
			if(i<n && virus.charAt(i) != virus.charAt(j)){
				if(j == 0){
					lps[i] = 0;
					i++;
				}
				else j = lps[j-1];
			}
		}
		return;
	}

	public String wrapper(String ts1,String ts2,String tvirus){
		s1 = ts1;
		s2 = ts2;
		virus = tvirus;

		n1 = s1.length();
		n2 = s2.length();
		n3 = virus.length();
		dp = new String[n1][n2][n3];
		lps = new int[n3];
		calculateLps(lps,virus);

		//System.out.println(Arrays.toString(lps));

		for(int i=0;i<n1;i++){
			for(int j=0;j<n2;j++){
				for(int k=0;k<n3;k++)
					dp[i][j][k] = "0";
			}
		}
		return rec(0,0,0).reverse().toString();
	}

	public void solve(String s1,String s2,String virus){
		int n1 = s1.length();
		int n2 = s2.length();
		int v = virus.length();
		int[][] dp = new int[108][108];

		for(int i=0;i<n1;i++)
			if(s1.charAt(i) == s2.charAt(0))
				dp[i][0] = 1;

		for(int i=0;i<n2;i++)
			if(s1.charAt(0) == s2.charAt(i))
				dp[0][i] = 1;

		for(int i=1;i<n1;i++){
			for(int j=1;j<n2;j++){
				if(s1.charAt(i) == s2.charAt(j)){
					dp[i][j] = dp[i-1][j-1]+1;
				}
				else dp[i][j] = Math.max(dp[i-1][j],dp[i][j-1]);
			}
		}
		System.out.println(dp[n1-1][n2-1]);
	}
}