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




public class Main {
	

	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception addd) {
					addd.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception addd) {
				addd.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	
	public static FastReader sc = new FastReader();
 
	static int mod = (int) (1e9+7),MAX=(int) (2e5);
    static List<Integer>[] edges;
	static char[] vir,s1,s2;
	static int[][][] dp;
	static int[] lps;
	public static void main(String[] args){
		
	  s1 = sc.next().toCharArray();
	  s2 = sc.next().toCharArray();
	  vir = sc.next().toCharArray();
	  lps = lps(new String(vir));
	  dp = new int[110][110][110];
	 
	 
	  for(int i=0;i<dp.length;++i) {
		  for(int j=0;j<dp[i].length;++j)
			  Arrays.fill(dp[i][j], -1);
	  }
	 
	  int ans = f(0,0,0);
	  if(ans == 0) out.print(0);
	  else print(0,0,0,"");
	  
	  
      out.close();
	}

	private static void print(int i, int j, int k, String str) {
		  if (i == s1.length || j == s2.length) {
		        out.print(str);
		        return;
		    }
		    int cur = dp[i][j][k];
		    int r = f(i+1,j,k);
		    if (r == cur){ print(i+1,j,k,str); return; }
		    r = f(i,j+1,k);
		    if (r == cur) { print(i,j+1,k,str); return; }
		 
		    while (k > 0 && vir[k] != s1[i]) k = lps[k - 1];
		    if (vir[k] == s1[i]) ++k;
		    print(i+1,j+1,k,str+s1[i]);
		
	}

	static int[] lps(String vir) {
	    int n = vir.length();
	    int[] pi = new int[n];
	    for (int i = 1; i < n; i++) {
	        int j = pi[i-1];
	        while (j > 0 && vir.charAt(i) != vir.charAt(j))
	            j = pi[j-1];
	        if (vir.charAt(i) == vir.charAt(j))
	            j++;
	        pi[i] = j;
	    }
	    return pi;
	}

	private static int f(int i, int j, int k) {
		if (k == vir.length) return -Integer.MIN_VALUE/10;
		if (i == s1.length) return 0;
		if (j == s2.length) return 0;
	 
		if(dp[i][j][k]!=-1) return dp[i][j][k];
	 
		int o1=0,o2=0,o3=0;
		
		if(s1[i] == s2[j]) {
			if(s1[i] == vir[k]) {
				o1 = 1 + f(i+1,j+1,k+1);
			}else {
				/*
				 * if next char don't match we can't reset k to 0
				 * becz now suffix of lcs = ....prefix of virus + s1[i] 
				 * the new k will be length of LPS of string = prefix of virus + s1[i]
				 */
			    while (k > 0 && vir[k] != s1[i]) k = lps[k-1];
			    if (s1[i] == vir[k]) k++;
				o1 = 1 + f(i+1,j+1,k);
			}
		}
		o2 = f(i+1,j,k);
		o3 = f(i,j+1,k);
	
		return dp[i][j][k] = Math.max(o1, Math.max(o2, o3));
	}


}