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.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class D {
	static BufferedReader stdin = new BufferedReader(new
			InputStreamReader(System.in));
	static StringTokenizer st = new StringTokenizer("");

	public static void main(String[] args) throws Exception {
		String s1 = readString();
		String s2 = readString();
		String virus = readString();
		int[] l = new int[virus.length()];
		for (int i = 2; i < virus.length(); ++i)
			for (int j = i - 1; j >= 1; --j)
				if (virus.substring(0, i).endsWith(virus.substring(0, j))) {
					l[i] = j;
					break;
				}
		Data[][][] data = new Data[s1.length() + 1][s2.length() + 1][virus.length()];
		for (Data[][] dd : data)
			for (Data[] d : dd)
				for (int i = 0; i < d.length; i++)
					d[i] = new Data();
		data[0][0][0].best = 0;
		for (int i = 0; i <= s1.length(); i++)
			for (int j = 0; j <= s2.length(); j++)
				for (int v = 0; v < virus.length(); v++)
					if (data[i][j][v].best >= 0) {
						int cbest = data[i][j][v].best;
						if (i + 1 <= s1.length()) {
							if (data[i + 1][j][v].best < cbest) {
								data[i + 1][j][v].best = cbest;
								data[i + 1][j][v].prevK = 1;
							}
						}
						if (j + 1 <= s2.length()) {
							if (data[i][j + 1][v].best < cbest) {
								data[i][j + 1][v].best = cbest;
								data[i][j + 1][v].prevK = 2;
							}
						}
						if (i + 1 <= s1.length() && j + 1 <= s2.length() && s1.charAt(i) == s2.charAt(j)) {
							int nv = v;
							char ch = s1.charAt(i);
							while (true) {
								if (virus.charAt(nv) == ch) {
									++nv;
									break;
								}
								if (nv == 0) break;
								nv = l[nv];
							}
							if (nv < virus.length()) {
								if (data[i + 1][j + 1][nv].best < 1 + cbest) {
									data[i + 1][j + 1][nv].best = 1 + cbest;
									data[i + 1][j + 1][nv].prevK = 3 + v;
								}
							}
						}
					}
		int pk = 0;
		for (int i = 1; i < virus.length(); i++)
			if (data[s1.length()][s2.length()][i].best > data[s1.length()][s2.length()][pk].best)
				pk = i;
		if (data[s1.length()][s2.length()][pk].best == 0) {
			System.out.println(0);
			return;
		}
		String res = "";
		int p1 = s1.length();
		int p2 = s2.length();
		while (p1 > 0 && p2 > 0) {
			switch (data[p1][p2][pk].prevK) {
			case 1:
				--p1;
				break;

			case 2:
				--p2;
				break;

			default:
				pk = data[p1][p2][pk].prevK - 3;
				--p1;
				--p2;
				res = s1.charAt(p1) + res;
				break;
			}
		}
		System.out.println(res);
	}
	
	static class Data {
		int best;
		int prevK;
		
		public Data() {
			best = -1;
			prevK = 0;
		}
	}
	
	static String readString() throws Exception {
		while (!st.hasMoreTokens()) {
			st = new StringTokenizer(stdin.readLine());
		}
		return st.nextToken();
	}
	
	static int readInt() throws Exception {
		return Integer.parseInt(readString());
	}
	
	static long readLong() throws Exception {
		return Long.parseLong(readString());
	}
	
	static double readDouble() throws Exception {
		return Double.parseDouble(readString());
	}
}