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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {
   	
	static char[] s1, s2;
	static int[][] aut, memo[];
	static int L;
	
	static int dp(int i, int j, int pi)
	{
		if(i == s1.length || j == s2.length)
			return 0;
		if(memo[i][j][pi] != -1)
			return memo[i][j][pi];
		int ret = Math.max(dp(i + 1, j, pi), dp(i, j + 1, pi)); 
		if(s1[i] == s2[j])
		{
			int piNxt = aut[s1[i]-'A'][pi];
			if(piNxt != L)
				ret = Math.max(ret, 1 + dp(i + 1, j + 1, piNxt));
		}
		return memo[i][j][pi] = ret;
	}
	
	static StringBuilder sb;
	
	static void print(int i, int j, int pi)
	{
		if(i == s1.length || j == s2.length)
			return;
		int opt = dp(i, j, pi);
		if(dp(i + 1, j, pi) == opt)
			print(i + 1, j, pi);
		else if(dp(i, j + 1, pi) == opt)
			print(i, j + 1, pi);
		else
		{
			sb.append(s1[i]);
			print(i + 1, j + 1, aut[s1[i]-'A'][pi]);
		}
	}
	
    public static void main(String[] args) throws IOException {
    
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
 
        s1 = sc.next().toCharArray();
        s2 = sc.next().toCharArray();
        String t = sc.next();
        L = t.length();
        aut = prefixAutomaton((t + "$").toCharArray());
        memo = new int[s1.length][s2.length][L];
        for(int[][] x1: memo)
        	for(int[] x2: x1)
        		Arrays.fill(x2, -1);
        int ans = dp(0, 0, 0);
        
        if(ans != 0)
        {
        	sb = new StringBuilder();
        	print(0, 0, 0);
        	out.println(sb);
        }
        else
        	out.println(0);
        out.flush();
        out.close();
    }
    
    static int[][] prefixAutomaton(char[] s)
    {
    	int n = s.length, k = 26;
    	int[] pi = new int[n];
    	for(int i = 1, j = 0; i < n; ++i)
    	{
    		while(j > 0 && s[j] != s[i])
    			j = pi[j - 1];
    		if(s[j] == s[i])
    			++j;
    		pi[i] = j;
    	}
    	int[][] aut = new int[k][n];
    	for(int c = 0; c < k; ++c)
    		for(int i = 0; i < n; ++i)
    			if(i > 0 && s[i] - 'A' != c)
    				aut[c][i] = aut[c][pi[i - 1]];
    			else
    				aut[c][i] = i + (s[i] - 'A' == c ? 1 : 0);
    	
    	return aut;
    }
    
    static class Scanner 
    {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public String next() throws IOException 
        {
            while (st == null || !st.hasMoreTokens()) 
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        
        public int nextInt() throws IOException {return Integer.parseInt(next());}

        public long nextLong() throws IOException {return Long.parseLong(next());}

        public String nextLine() throws IOException {return br.readLine();}

        public boolean ready() throws IOException {return br.ready(); }


    }
    
}