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.lang.*;
import java.io.*;
 
 public class Solution
{
    static char[] a;
    static char[] b;
    static char[] v;
    static int[][][] dp;
    static int[] suffix;
    static StringBuilder sb = new StringBuilder();
    public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		
		a = br.readLine().toCharArray();
		b = br.readLine().toCharArray();
		v = br.readLine().toCharArray();
		
		dp = new int[a.length][b.length][v.length];
		for(int i=0;i<dp.length;i++)
		 for(int j=0;j<dp[0].length;j++) Arrays.fill(dp[i][j],-1);
		 
		 computeKMPArray();
		int sol = LCS(a.length-1,b.length-1,v.length-1);
		if(sol <= 0) out.println("0");
		else{
		    backTrackPath(a.length-1,b.length-1,v.length-1);
		    out.println(sb.toString());
		} 
 
		out.close();
    }
    
    public static void backTrackPath(int i,int j,int k){
       while(i>=0 && j>= 0){
            int top = (i==0) ? 0 : dp[i-1][j][k];
            int left = (j== 0)? 0: dp[i][j-1][k];
            
            int k2 = k;
            if(a[i] == b[j]){
            while(k2 < v.length-1 && a[i] != v[k2]) k2 = suffix[k2+1];
            if(a[i] == v[k2]) k2--;
            int diagonal  = (i==0 || j==0 || k2 == -1) ? 0: 1+dp[i-1][j-1][k2];
        }
             if(top == dp[i][j][k]) i--;
             else if(left == dp[i][j][k]) j--;
             else{
                 sb.insert(0,a[i]);
                 i--;
                 j--;
                 k = k2;
             }
       }
    }
    
    
    public static int LCS(int i,int j,int k){
        if(k == -1) return -1000000;
        if(i<0 || j<0) return 0;
        if(dp[i][j][k] != -1) return dp[i][j][k];
        int max = Integer.MIN_VALUE;
        
        if(a[i] == b[j]){
            int k2 = k;
            while(k2 < v.length-1 && a[i] != v[k2]) k2 = suffix[k2+1];
            if(a[i] == v[k2]) k2--;
            max = 1+LCS(i-1,j-1,k2);
        }
        
         return  dp[i][j][k] = Math.max(max,Math.max(LCS(i-1,j,k),LCS(i,j-1,k)));
        
    }
    
    public static void computeKMPArray(){
        int k=v.length-1;
        suffix = new int[v.length];
        suffix[v.length-1]= k;
         for(int i=v.length-2;i>=0;i--){
             while(k < v.length-1 && v[i] != v[k]) k = suffix[k+1];
             if(v[i]==v[k]) k--;
             suffix[i] = k;
         }
         
    }
	
}