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

public class ProblemB {
	
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		
		char[] s1 = in.readLine().toCharArray();
		char[] s2 = in.readLine().toCharArray();
		char[] v = in.readLine().toCharArray();
		int l1 = s1.length;
		int l2 = s2.length;
		int l3 = v.length;
		
		int[][][] dp = new int[l1+1][l2+1][l3+1];
		int[][][][] prv = new int[l1+1][l2+1][l3+1][2];
		for (int i = 0 ; i <= l1 ; i++) {
			for (int j = 0 ; j <= l2 ; j++) {
				Arrays.fill(dp[i][j], -1);
			}
		}
		String virus = String.valueOf(v);

		int[][] map = new int[l3][26];
		String pre = "";
		for (int i = 0 ; i < l3 ; i++) {
			for (int j = 0 ; j < 26 ; j++) {
				String tr = pre + (char)('A' + j);
				int tw = 0;
				for (int x = 0 ; x < tr.length() ; x++) {
					String f = tr.substring(x);
					if (virus.startsWith(f)) {
						tw = f.length();
						break;
					}
				}
				map[i][j] = tw;
			}
			pre += v[i]; 
		}
		
		
		dp[0][0][0] = 0;
		for (int i = 0 ; i <= l1 ; i++) {
			for (int j = 0 ; j <= l2 ; j++) {
				for (int k = 0 ; k < l3 ; k++) {
					if (dp[i][j][k] == -1) {
						continue;
					}
					int base = dp[i][j][k];
					if (i < l1) {
						if (dp[i+1][j][k] < base) {
							dp[i+1][j][k] = base;
							prv[i+1][j][k][0] = 1;
							prv[i+1][j][k][1] = k;
						}
					}
					if (j < l2) {
						if (dp[i][j+1][k] < base) {
							dp[i][j+1][k] = base;
							prv[i][j+1][k][0] = 2;
							prv[i][j+1][k][1] = k;
						}
					}
					if (i < l1 && j < l2 && s1[i] == s2[j]) {
						int tk = map[k][s1[i]-'A'] ; //(v[k] == s1[i]) ? k + 1 : map[k][s1[i]-'A'];
						if (dp[i+1][j+1][tk] < base + 1) {
							dp[i+1][j+1][tk] = base + 1;
							prv[i+1][j+1][tk][0] = 3;
							prv[i+1][j+1][tk][1] = k;
						}
					}
				}
			}
		}
		
		
		int max = 0;
		int maxk = -1;
		for (int k = 0 ; k < l3 ; k++) {
			if (max < dp[l1][l2][k]) {
				max = dp[l1][l2][k];
				maxk= k;
			}
		}
		if (max == 0) {
			out.println(0);
			out.flush();
			return;
		}
		char[] ans = new char[max];
		int nowi = l1;
		int nowj = l2;
		int nowk = maxk;
		int gi = max-1;
		while (nowi > 0 || nowj > 0) {
			int ti = nowi;
			int tj = nowj;
			int tk = prv[nowi][nowj][nowk][1];
			if (prv[nowi][nowj][nowk][0] == 1) {
				ti--;
			} else if (prv[nowi][nowj][nowk][0] == 2) {
				tj--;
			} else {
				ti--;
				tj--;
				ans[gi] = s1[ti];
				gi--;
			}
			nowi = ti;
			nowj = tj;
			nowk = tk;
		}
		out.println(String.valueOf(ans));
		out.flush();
	}
	
	
	public static void debug(Object... o) {
		System.err.println(Arrays.deepToString(o));
	}
}