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.BufferedInputStream;
import java.io.PrintStream;
import java.util.Scanner;


public class D {

	private static PrintStream out = System.out;
	private static Scanner in = new Scanner(new BufferedInputStream(System.in));
	
	private static char[] s1;
	private static char[] s2;
	private static char[] v;
	
	private static int fix(char x, int idx) {
		char[] s = new char[v.length - idx];
		s[0] = x;
		for (int i = idx + 1; i < v.length; ++i)
			s[i - idx] = v[i];
		for (int len = s.length - 1; len >= 0; --len) {
			boolean found = true;
			for (int i = 0; i < len; ++i)
				if (s[i] != s[s.length - len + i])
					found = false;
			if (found)
				return len;
		}
		throw new RuntimeException();
	}
	
	private static String[][][] cache = new String[101][101][101];
	private static String dp(int a, int b, int i) {
		// seen before
		if (cache[a][b][i] != null)
			return cache[a][b][i];
		// base case
		if (a == 0 || b == 0)
			return "";
		// recursive case
		String res1 = dp(a - 1, b, i);
		String res2 = dp(a, b - 1, i);
		String ret = res1.length() >= res2.length() ? res1 : res2;
		if (s1[a - 1] == s2[b - 1]) {
			String res = "";
			char x = s1[a - 1];
			if (x == v[i] && i > 0)
				res = dp(a - 1, b - 1, i - 1) + x;
			else if (x != v[i])
				res = dp(a - 1, b - 1, v.length - 1 - fix(x, i)) + x;
			if (ret.length() < res.length())
				ret = res;
		}
		return cache[a][b][i] = ret;
	}
	
	public static void main(String[] args) {
		s1 = in.next().toCharArray();
		s2 = in.next().toCharArray();
		v = in.next().toCharArray();
		String ans = dp(s1.length, s2.length, v.length - 1);
		out.println(ans.equals("") ? "0" : ans);
	}

}