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.*;
public class D{
	static List<String> prefixes;
	static Map<String, Integer> prefixesMap;
	static String s1;
	static String s2;
	static String s3;
	static int [][][] memo;
	static int rec(int i, int j, int p){
		if (i < 0 || j < 0){
			return 0;
		}
		if (memo[i][j][p] != 0){
			return memo[i][j][p] - 1;
		}
		int res = 0;
		if (s1.charAt(i) == s2.charAt(j)){
			final String currentPrefix = prefixes.get(p);
			final String newPrefix = s1.charAt(i) + currentPrefix;
			int m = newPrefix.length();
			while (m >= 0 && !s3.endsWith(newPrefix.substring(0, m))){
				--m;
			}
			if (m < s3.length()){
				res = Math.max(res, rec(i - 1, j - 1, prefixesMap.get(newPrefix.substring(0, m))) + 1);					
			}
		}
		res = Math.max(res, rec(i - 1, j, p));
		res = Math.max(res, rec(i, j - 1, p));
		memo[i][j][p] = res + 1;
		return res;
	}
	static String trace(int i, int j, int p){
		if (i < 0 || j < 0){
			return "";
		}
		final int m1 = rec(i - 1, j, p);
		final int m2 = rec(i, j - 1, p);
		if (s1.charAt(i) == s2.charAt(j)){
			final String currentPrefix = prefixes.get(p);
			final String newPrefix = s1.charAt(i) + currentPrefix;
			int m = newPrefix.length();
			while (m >= 0 && !s3.endsWith(newPrefix.substring(0, m))){
				--m;
			}
			if (m < s3.length()){
				final int newPrefixPos = prefixesMap.get(newPrefix.substring(0, m));
				if (rec(i - 1, j - 1, newPrefixPos) + 1 > Math.max(m1, m2)){
					return trace(i - 1, j - 1, newPrefixPos) + s1.charAt(i);
				}	
			}
		}
		return m1 > m2 ? trace(i - 1, j, p) : trace(i, j - 1, p);
	}

	public static void main(String [] args){
		final Scanner s = new Scanner(System.in);
		s1 = s.nextLine();
		s2 = s.nextLine();
		s3 = s.nextLine();
		memo = new int[s1.length()][s2.length()][s3.length() + 1];
		prefixes = new ArrayList<String>(s3.length() + 1);
		prefixesMap = new HashMap<String, Integer>();
		for (int i = s3.length(); i >= 0; --i){
			final String prefix = s3.substring(i);
			prefixesMap.put(prefix, prefixes.size());
			prefixes.add(prefix);
		}
		final int res = rec(s1.length() - 1, s2.length() - 1, 0);
		if (res == 0){
			System.out.println(0);
		}else{
			System.out.println(trace(s1.length() - 1, s2.length() - 1, 0));
		}
		s.close();
	}
}