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.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
	
	void solve() throws Exception {
		String a = sc.nextToken();
		String b = sc.nextToken();
		String c = sc.nextToken();
		int dp1[][] = new int[c.length()][26];
		for (int i = 0; i < c.length(); i++) {
			for (int j = 0; j < 26; j++) {
				if (c.charAt(i) - 'A' == j) {
					dp1[i][j] = i + 1;
				} else {
					dp1[i][j] = 0;
					for (int k = i; k >= 0; --k) {
						if (c.startsWith(c.substring(i - k, i) + (char)('A' + j))) {
							dp1[i][j] = k + 1;
							break;
						}
					}
				}
			}
		}
		String dp[][][] = new String[2][b.length() + 1][c.length()];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j <= b.length(); j++) {
				for (int k = 0; k < c.length(); k++) {
					dp[i][j][k] = "";
				}
			}
		}
		for (int i = 0; i < a.length(); i++) {
			int X = (i & 1);
			int Y = X ^ 1;
			for (int j = 0; j < b.length(); j++) {
				if (a.charAt(i) == b.charAt(j)) {
					for (int k = 0; k < c.length(); k++) {
						if (dp1[k][a.charAt(i) - 'A'] != c.length()) {
							if (dp[Y][j + 1][dp1[k][a.charAt(i) - 'A']].length() < dp[X][j][k].length() + 1) {
								dp[Y][j + 1][dp1[k][a.charAt(i) - 'A']] = dp[X][j][k] + a.charAt(i);
							}
						}
					}
				} else {
					for (int k = 0; k < c.length(); k++) {
						if (dp[X][j + 1][k].length() < dp[X][j][k].length()) {
							dp[X][j + 1][k] = new String(dp[X][j][k]);
						}
					}
				}
			}
			for (int j = 0; j <= b.length(); j++) {
				for (int k = 0; k < c.length(); k++) {
					if (dp[Y][j][k].length() < dp[X][j][k].length()) {
						dp[Y][j][k] = new String(dp[X][j][k]);
					}
				}
			}
		}
		String ans = "";
		for (int j = 0; j <= b.length(); j++) {
			for (int k = 0; k < c.length(); k++) {
				if (ans.length() < dp[a.length() & 1][j][k].length()) {
					ans = dp[a.length() & 1][j][k];
				}
			}
		}
		if (ans.equals(""))
			out.println(0);
		else
			out.println(ans);
	}
	
	BufferedReader in;
	PrintWriter out;
	FastScanner sc;
	
	static Throwable throwable;
	
	public static void main(String[] args) throws Throwable {
		Thread thread = new Thread(null, new Solution(), "", (1 << 26));
		thread.start();
		thread.join();
		thread.run();
		if (throwable != null)
			throw throwable;
	}
	
	
	public void run() {
		try {
			//in = new BufferedReader(new FileReader(".in"));
			//out = new PrintWriter(new FileWriter(".out"));
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Exception e) {
			throwable = e;
		} finally {
			out.close();
		}
	}
}

class FastScanner {
	BufferedReader reader;
	StringTokenizer strTok;
	
	FastScanner(BufferedReader reader) {
		this.reader = reader;
	}
	
	public String nextToken() throws Exception {
		while (strTok == null || !strTok.hasMoreTokens())
			strTok = new StringTokenizer(reader.readLine());
		return strTok.nextToken();
	}
	
	public int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}
	
	public long nextLong() throws Exception {
		return Long.parseLong(nextToken());
	}
	
	public double nextDouble() throws Exception {
		return Double.parseDouble(nextToken());
	}
}