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

public class b
{
	static AhoCorasick ac;
	static String a, b, v, ans;
	static int memo[][][];
	public static void main(String[] args)
	{
		FastScanner in = new FastScanner();
		a = in.next().toLowerCase();
		b = in.next().toLowerCase();
		v = in.next().toLowerCase();
		ac.createAhoCorasick(new String[]{v});
		memo = new int[a.length()][b.length()][ac.nodeCount];
		ans = "";
		
		for(int l[][] : memo)
			for(int m[] : l)
				Arrays.fill(m, -1);
		
		go(0, 0, 0);
		rec(0, 0, 0);
		
		if(ans.length() == 0)
			ans = "0";
		System.out.println(ans.toUpperCase());
	}
	
	private static void rec(int i, int j, int aho)
	{
		if(ac.term[aho])
			return;
		if(i >= a.length() || j >= b.length())
			return;
		
		int ans1 = go(i+1, j, aho);
		int ans2 = go(i, j+1, aho);
		int ans3 = Integer.MIN_VALUE;
		if(a.charAt(i) == b.charAt(j))
			ans3 = 1+go(i+1, j+1, ac.transition[a.charAt(i)-'a'][aho]);
		
		if(ans1 >= ans2 && ans1 >= ans3)
			rec(i+1, j, aho);
		else if(ans2 >= ans1 && ans2 >= ans3)
			rec(i, j+1, aho);
		else
		{
			ans += a.charAt(i);
			rec(i+1, j+1, ac.transition[a.charAt(i)-'a'][aho]);
		}
	}
	
	private static int go(int i, int j, int aho)
	{
		if(ac.term[aho])
			return -Integer.MAX_VALUE/4;
		if(i >= a.length() || j >= b.length())
			return 0;
		if(memo[i][j][aho] != -1)
			return memo[i][j][aho];
		
		int ans = go(i+1, j, aho);
		ans = Math.max(ans, go(i, j+1, aho));
		if(a.charAt(i) == b.charAt(j))
			ans = Math.max(ans, 1+go(i+1, j+1, ac.transition[a.charAt(i)-'a'][aho]));
		
		return memo[i][j][aho] = ans;
	}

	static class AhoCorasick {
		static final int ALPHA = 26;
		static int nodeCount, transition[][];
		static boolean[] term;
		static void createAhoCorasick(String[] strs) {
			int maxNodes = 1;
			for(String s : strs) maxNodes += s.length();

			int[][] children = new int[ALPHA][maxNodes];
			boolean[] leaf = new boolean[maxNodes];
			nodeCount = 1;
			for(String s : strs) {
				int node = 0;
				for(char ch : s.toCharArray()) {
					int c = ch - 'a';
					if(children[c][node] == 0) children[c][node] = nodeCount++;
					node = children[c][node];
				}
				leaf[node] = true;
			}

			transition = new int[ALPHA][nodeCount];
			term = new boolean[nodeCount];

			ArrayDeque<Integer> queue = new ArrayDeque<>();
			queue.add(0);  queue.add(0);

			while(queue.size() > 0) {
				int node = queue.remove(), suffLink = queue.remove();

				term[node] = leaf[node] || term[suffLink];

				for(int ch = 0; ch < ALPHA; ch++) {
					if(children[ch][node] != 0){
						transition[ch][node] = children[ch][node];
						queue.add(children[ch][node]);
						queue.add(node == 0 ? 0 : transition[ch][suffLink]);
					} else  transition[ch][node] = transition[ch][suffLink];
				}
			}
		}
	}
	
	public static class FastScanner
	{
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s)
		{
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner()
		{
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken()
		{
			while (st == null || !st.hasMoreElements())
			{
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(nextToken());
		}

		long nextLong()
		{
			return Long.parseLong(nextToken());
		}

		double nextDouble()
		{
			return Double.parseDouble(nextToken());
		}
		
		String next()
		{
			return nextToken();
		}
	}
}
