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:
//package codeforces201;

import java.io.File;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: Bauka
 * Date: 7/6/14
 * Time: 8:14 AM
 * To change this template use File | Settings | File Templates.
 */
public class Solver {
    String[][][] dp = new String[105][105][105];
    public static void main(String [] args) throws Exception{
        new Solver().work();
        //new Solver().ppd();

    }
    public int[] prefix_function(String s){
         int n = s.length();
        int [] ret = new int[n];
        for(int i=1;i<n;i++){
            int j = ret[i-1];
            while(j > 0 && s.charAt(i)!=s.charAt(j))
                j = ret[j-1];
            if(s.charAt(i) == s.charAt(j)) ++j;
            ret[i] = j;
        }
        return ret;
    }
    public String f(String a,String b){
        if(b.length() > a.length()) return b;
        return a;
    }
    public void ppd() throws Exception{
        Scanner in = new Scanner(new File("a.txt"));
        String s1 = in.next();
        String s2 = in.next();

        int n = s1.length();
        int m = s2.length();

        int [][] dp = new int[n ][m ];

        for(int i=0;i<n;i++)
           dp[i][0] = (s1.charAt(i) == s2.charAt(0) ? 1 : 0);

        for(int j=0;j<m;j++)
           dp[0][j] = (s1.charAt(0) == s2.charAt(j) ? 1 : 0);

        for(int i=1;i<n;i++)
        for(int j=1;j<m;j++)
        {
            dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
            if(s1.charAt(i)==s2.charAt(j))
                dp[i][j] = dp[i-1][j-1] + 1;
        }

        System.out.println(dp[n-1][m-1]);
    }
    public void work() throws Exception{
        //Scanner in = new Scanner(new File("a.txt"));
        Scanner in = new Scanner(System.in);
        String s1 = in.next();
        String s2 = in.next();
        String v  =  in.next();
        int[] pi = prefix_function(v);
        for(int i=0;i<105;i++) for(int j=0;j<105;j++) for(int k=0;k<105;k++)
            dp[i][j][k] = "";

        int n = s1.length();
        int m = s2.length();
        int p = v.length();

        /*for(int i=0;i<n;i++)
            if(s1.charAt(i) == s2.charAt(0))
                dp[i][0][ (v.charAt(0) == s1.charAt(i) ? 1 : 0) ] = s1.charAt(i) + "";

        for(int j=0;j<m;j++)
            if(s1.charAt(0) == s2.charAt(j))
                dp[0][j][ ( v.charAt(0) == s1.charAt(0) ? 1 : 0) ] = s1.charAt(0) + "";
        */

        for(int i=1; i <= n; i++)
          for(int j=1;j <= m;j++)
             for(int k=0;k<=p;k++)
                {
                    dp[i][j][k] = f(dp[i-1][j][k], dp[i][j-1][k]);

                    //if(s1.charAt(i - 1) == s2.charAt(j-1) && k > 0)
                    //    dp[i][j][k] = dp[i-1][j-1][k-1] + s1.charAt(i-1);

                    if(s1.charAt(i - 1) == s2.charAt(j - 1) && k > 0)
                      if (v.charAt(k - 1) == s1.charAt(i - 1) )
                         dp[i][j][k] = f(dp[i][j][k], dp[i-1][j-1][k-1] + s1.charAt(i - 1));
                      else{
                         int x = k > 1 ? pi[k-2] : 0;
                         while(x > 0 && v.charAt(x)!=s1.charAt(i - 1))
                             x = pi[x-1];

                         int r = x + (v.charAt(x)==s1.charAt(i-1) ? 1 : 0 ) ;
                         dp[i][j][r] = f( dp[i][j][r], dp[i-1][j-1][k-1] + s1.charAt(i - 1) ) ;
                      }
                }

        //System.out.println(dp[4][4][3]);
        //int x = pi[3];
        //while(x > 0 && v.charAt(x)!=s1.charAt(4))
        //    x = pi[x-1];
        //System.out.println( x );

        ///if(1==1) return;
        String ret = "";
        for(int i=0;i<p ;i++)
            ret = f(ret , dp[n][m][i]);

        if(ret.equals(""))
            System.out.println(0);
        else
            System.out.printf("%s",ret);


    }
}