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;


public class LuckyCommonSubsequence {
	private static int[] failure;
	private static String s;
	private static String t;
	private static String virus;
	private static int[][][] dp; 
	private static int[][][][] next;
	private static int x;
	private static int y;
	private static int z;
	private static int globalMax;
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		s = br.readLine();
		t = br.readLine();
		virus = br.readLine();
		failure = new int[virus.length()];
		dp = new int[s.length()+1][t.length()+1][virus.length()+1];
		next = new int[s.length()+1][t.length()+1][virus.length()+1][4];
		globalMax = 0;
		x = y = z = -1;
		for(int i = 0; i <= s.length(); i++) {
			for(int j = 0; j <= t.length(); j++) {
				for(int k = 0; k <= virus.length(); k++) {
					dp[i][j][k] = -1;
					next[i][j][k][0] = -1;
					next[i][j][k][1] = -1;
					next[i][j][k][2] = -1;
					next[i][j][k][3] = -1;
				}
			}
		}
		computeFailure();
		int lcs = solve(0,0,0);
		if(lcs == 0){
			System.out.println(0);
		} else {
			while(next[x][y][z][0] != -1) {
				if(next[x][y][z][3] != -1) {
					System.out.print(s.charAt(next[x][y][z][3]));
				}
				int X = next[x][y][z][0];
				int Y = next[x][y][z][1];
				int Z = next[x][y][z][2];
				x = X;
				y = Y;
				z = Z;
			}
		}
		br.close();
	}
	
	private static int solve(int i, int j, int k) {
		if(i >= s.length() || j >= t.length()) {
			return 0;
		}
		if(dp[i][j][k] != -1)return dp[i][j][k];
		int max = 0;
		int tempK = k;
		if(s.charAt(i) == t.charAt(j)) {
			while(k > 0 && virus.charAt(k) != s.charAt(i)) {
				k = failure[k-1];
			}
			if(virus.charAt(k) == s.charAt(i))k++;
			if(k < virus.length()) {
				max = Math.max(max, 1+solve(i+1,j+1,k));
				next[i][j][tempK][0] = i+1;
				next[i][j][tempK][1] = j+1;
				next[i][j][tempK][2] = k;
				next[i][j][tempK][3] = i;
				
			}
		}
		int leftMax = solve(i+1, j, tempK);
		if(leftMax > max) {
			max = leftMax;
			next[i][j][tempK][0] = i+1;
			next[i][j][tempK][1] = j;
			next[i][j][tempK][2] = tempK;
			next[i][j][tempK][3] = -1;
		}
		int rightMax = solve(i, j+1, tempK);
		if(rightMax > max) {
			max = rightMax;
			next[i][j][tempK][0] = i;
			next[i][j][tempK][1] = j+1;
			next[i][j][tempK][2] = tempK;
			next[i][j][tempK][3] = -1;
		}
		
		if(max > globalMax) {
			x = i;
			y = j;
			z = tempK;
		}
		return dp[i][j][tempK] = max;
	}
	
	private static void computeFailure() {
		failure[0] = 0;
		int i = 1;
		int j = 0;
		while(i < virus.length()) {
			while(j > 0 && virus.charAt(j) != virus.charAt(i)) {
				j = failure[j-1];
			}
			if(virus.charAt(j) == virus.charAt(i))j++;
			failure[i++] = j;
		}
//		for(i = 0; i < failure.length; i++) {
//			System.out.println(failure[i]);
//		}
	} 
}