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.math.*;
import java.io.*;
import java.text.DecimalFormat;
import java.math.BigInteger;
public class Main{
    static int d=20,n;
    static long mod=(long)Math.pow(2,32) ;
    static  ArrayList<ArrayList<Integer>> arr;
    static int[] a,b,c; 
    public static void main(String[] args)  throws IOException {
        s.init(System.in);   
        
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        char[] a=s.ns().toCharArray();
        char[] b=s.ns().toCharArray();
        char[] v=s.ns().toCharArray();
        int[] p=new int[v.length];
        for(int i=1;i<v.length;i++){
            int x=p[i-1];
            while(x>0 && v[i]!=v[x])
                x=p[x-1];
            if(v[i]==v[x])
                x++;
            p[i]=x;

        }
     
        int[][] d=new int[v.length][26];
        for(int i=0;i<v.length;i++ ){
            int x=v[i]-'A';
            for(int j=0;j<26;j++){
                if(i>0 && j!=x)
                    d[i][j]=d[p[i-1]][j];
                else
                    d[i][j]=i+(j==x?1:0);
                


            }
        }
        int[][][] dp=new int[a.length+1][b.length+1][v.length];
        int[][][] pd=new int[a.length+1][b.length+1][v.length];
        for(int i=0;i<=a.length;i++){
            for(int j=0;j<=b.length;j++){
                    Arrays.fill(dp[i][j],-1);
            }
        }
        dp[0][0][0]=0;
        for(int i=0;i<=a.length;i++){
            for(int j=0;j<=b.length;j++){
                
                for(int k=0;k<v.length;k++){
                    int val=dp[i][j][k];
                    if(val==-1)
                        continue;
                    if(i<a.length && dp[i+1][j][k]<val){
                        dp[i+1][j][k]=val;
                        pd[i+1][j][k]=-1;
                    }
                    if(j<b.length && dp[i][j+1][k]<val){
                        dp[i][j+1][k]=val;
                        pd[i][j+1][k]=-2;
                    }
                    if(i<a.length && j<b.length && a[i]==b[j]){

                        int z=d[k][a[i]-'A'];
                        if(z!=v.length && dp[i+1][j+1][z]<val+1){
                            dp[i+1][j+1][z]=val+1;
                            pd[i+1][j+1][z]=k;
                        }
                    }
                }
            }
        }
        int ans=-1;
        int state=-1;
        for(int i=0;i<v.length;i++){
            if(dp[a.length][b.length][i] > ans){
                ans=dp[a.length][b.length][i];              
                state=i;
            }
        }
        if(ans<=0){
            out.println(0);

        }
        else{
            int i=a.length;
            int j=b.length;
            StringBuilder sb = new StringBuilder();
            while(i>0 && j>0){
               
                int t=pd[i][j][state];
                if(t>=0){
                    sb.append(a[i-1]);
                    state=pd[i][j][state];
                    i--;
                    j--;
                }
                else if(t==-1)
                    i--;
                else
                    j--;

            }
            out.println(sb.reverse().toString());
        }

        out.close();
    }

  
    public static class s {
        static BufferedReader reader;
        static StringTokenizer tokenizer;
 
        /** call this method to initialize reader for InputStream */
        static void init(InputStream input) {
            reader = new BufferedReader(
                        new InputStreamReader(input) );
            tokenizer = new StringTokenizer("");
        }   
 
        /** get next word */
        static String ns() throws IOException {
            while ( ! tokenizer.hasMoreTokens() ) {
                //TODO add check for eof if necessary
                tokenizer = new StringTokenizer(
                    reader.readLine() );
            }
            return tokenizer.nextToken();
        }
 
        static int ni() throws IOException {
            return Integer.parseInt( ns() );
        }
    
        static double nd() throws IOException {
            return Double.parseDouble( ns() );
        }
        static long nl() throws IOException {
            return Long.parseLong( ns() );
        }
        
    }
}