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

public class B implements Runnable {
	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer st;
	static Random rnd;

	final char baseChar = 'A';
	final int maxCode = 26;

	private void solve() throws IOException {
		String s1 = nextToken(), s2 = nextToken(), virus = nextToken();
		int[][] automaton = buildAutomaton(virus);

		int[][][] d = new int[s1.length() + 1][s2.length() + 1][virus.length() + 1], x = new int[s1
				.length() + 1][s2.length() + 1][virus.length() + 1], y = new int[s1
				.length() + 1][s2.length() + 1][virus.length() + 1], z = 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++) {
					// take
					if (i < s1.length() && j < s2.length()
							&& s1.charAt(i) == s2.charAt(j)) {
						int ni = i + 1, nj = j + 1, nk = automaton[k][s1
								.charAt(i) - 'A'];

						if (d[i][j][k] + 1 > d[ni][nj][nk]) {
							d[ni][nj][nk] = d[i][j][k] + 1;
							x[ni][nj][nk] = i;
							y[ni][nj][nk] = j;
							z[ni][nj][nk] = k;
						}
					}

					if (i < s1.length()) {
						int ni = i + 1, nj = j, nk = k;

						if (d[i][j][k] > d[ni][nj][nk]) {
							d[ni][nj][nk] = d[i][j][k];
							x[ni][nj][nk] = i;
							y[ni][nj][nk] = j;
							z[ni][nj][nk] = k;
						}
					}

					if (j < s2.length()) {
						int ni = i, nj = j + 1, nk = k;

						if (d[i][j][k] > d[ni][nj][nk]) {
							d[ni][nj][nk] = d[i][j][k];
							x[ni][nj][nk] = i;
							y[ni][nj][nk] = j;
							z[ni][nj][nk] = k;
						}
					}
				}
			}
		}

		int resultZ = 0;
		for (int i = 0; i < virus.length(); i++) {
			if (d[s1.length()][s2.length()][i] > d[s1.length()][s2.length()][resultZ]) {
				resultZ = i;
			}
		}

		int result = d[s1.length()][s2.length()][resultZ];

		if (result == 0) {
			out.println(result);
		} else {
			StringBuilder sb = new StringBuilder();
			int xp = s1.length(), yp = s2.length(), zp = resultZ;

			while (xp != 0 || yp != 0 || zp != 0) {
				int nxp = x[xp][yp][zp];
				int nyp = y[xp][yp][zp];
				int nzp = z[xp][yp][zp];
				if (d[xp][yp][zp] != d[nxp][nyp][nzp]) {
					sb.append(s1.charAt(nxp));
				}
				xp = nxp;
				yp = nyp;
				zp = nzp;
			}

			sb = sb.reverse();
			//out.println(d[s1.length()][s2.length()][resultZ]);

			out.println(sb);

		}
	}

	private int[][] buildAutomaton(String s) {
		int[][] automaton = new int[s.length()][maxCode];

		for (int i = 0; i < s.length(); i++) {
			for (int j = 0; j < maxCode; j++) {
				char c = (char) (baseChar + j);
				String toCheck = s.substring(0, i) + c;

				search: for (int remove = 0; remove <= (i + 1); remove++) {
					String toCheckCur = toCheck.substring(remove,
							toCheck.length());

					if (s.startsWith(toCheckCur)) {
						automaton[i][j] = toCheckCur.length();
						break search;
					}
				}
			}
		}

		return automaton;
	}

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

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null)
				return null;

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

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

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

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