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

public class B {

	void solve() throws IOException {
		String s1 = next();
		String s2 = next();
		String virus = next();
		int[][] next = new int[virus.length() + 1][300];
		for (int i = 0; i < virus.length(); i++) {
			for (char val = 'A'; val <= 'Z'; val++) {
				String cur = virus.substring(0, i) + val;
				for (int len = 1; len <= cur.length(); len++) {
					if (cur.substring(cur.length() - len).equals(
							virus.substring(0, len))) {
						next[i][val] = len;
					}
				}
			}
		}
		int[][][] dp = new int[s1.length() + 1][s2.length() + 1][virus.length() + 1];
		for (int i = 0; i < s1.length() + 1; i++) {
			for (int j = 0; j < s2.length() + 1; j++) {
				Arrays.fill(dp[i][j], -1);
			}
		}
		dp[0][0][0] = 0;
		int[][][] par = new int[s1.length() + 1][s2.length() + 1][virus
				.length() + 1];
		for (int i = 0; i <= s1.length(); i++) {
			for (int j = 0; j <= s2.length(); j++) {
				for (int k = 0; k < virus.length(); k++) {
					if (dp[i][j][k] >= 0) {
						if (i < s1.length() && dp[i + 1][j][k] < dp[i][j][k]) {
							dp[i + 1][j][k] = dp[i][j][k];
							par[i + 1][j][k] = -1;
						}
						if (j < s2.length() && dp[i][j + 1][k] < dp[i][j][k]) {
							dp[i][j + 1][k] = dp[i][j][k];
							par[i][j + 1][k] = -2;
						}
						if (i < s1.length() && j < s2.length()
								&& s1.charAt(i) == s2.charAt(j)) {
							if (dp[i + 1][j + 1][next[k][s1.charAt(i)]] < dp[i][j][k] + 1) {
								dp[i + 1][j + 1][next[k][s1.charAt(i)]] = dp[i][j][k] + 1;
								par[i + 1][j + 1][next[k][s1.charAt(i)]] = k;
							}
						}
					}
				}
			}
		}
		int posMax = 0;
		for (int i = 0; i < virus.length(); i++) {
			if (dp[s1.length()][s2.length()][i] > dp[s1.length()][s2.length()][posMax]) {
				posMax = i;
			}
		}
		if (dp[s1.length()][s2.length()][posMax] <= 0) {
			out.println(0);
			return;
		}
		int n = s1.length();
		int m = s2.length();
		int k = posMax;
		String res = "";
		while (n > 0 && m > 0) {
			if (par[n][m][k] == -1) {
				n--;
				continue;
			}
			if (par[n][m][k] == -2) {
				m--;
				continue;
			}
			res = s1.charAt(n - 1) + res;
			k = par[n][m][k];
			n--;
			m--;
		}
		out.println(res);

	}

	void run() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new B().run();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer str;

	String next() throws IOException {
		while (str == null || !str.hasMoreTokens()) {
			str = new StringTokenizer(br.readLine());
		}
		return str.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

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

}