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

public class B {

	static char[] a, b, c;
	static int[][][] dp;
	static int[] bk;

	static void build() {
		bk[0] = bk[1] = 0;
		for (int i = 2; i <= c.length; i++) {
			int j = bk[i - 1];
			for (;;) {
				if (c[j] == c[i - 1]) {
					bk[i] = j + 1;
					break;
				}
				if (j == 0) {
					bk[i] = 0;
					break;
				}
				j = bk[j];
			}
		}
	}

	static int solve(int i, int j, int k) {
		if (k == c.length)
			return -999999;
		if (i == a.length || j == b.length)
			return 0;
		if (dp[i][j][k] != -1)
			return dp[i][j][k];
		int ans = Math.max(solve(i, j + 1, k), solve(i + 1, j, k));
		if (a[i] == b[j]) {
			int next = k;
			while (next > 0 && a[i] != c[next])
				next = bk[next];
			if (a[i] == c[next])
				next++;
			ans = Math.max(1 + solve(i + 1, j + 1, next), ans);
		}
		return dp[i][j][k] = ans;
	}

	static void prnt(int i, int j, int k) {
		if (i == a.length || j == b.length || k == c.length)
			return;
		int x = solve(i, j + 1, k);
		int y = solve(i + 1, j, k);
		int z = Integer.MIN_VALUE;
		int next = k;
		if (a[i] == b[j]) {
			while (next > 0 && a[i] != c[next])
				next = bk[next];
			if (a[i] == c[next])
				next++;
			z = 1 + solve(i + 1, j + 1, next);
		}
		int ans = Math.max(z, Math.max(x, y));
		if (ans == z) {
			out.print(a[i]);
			prnt(i + 1, j + 1, next);
		} else if (ans == x)
			prnt(i, j + 1, k);
		else
			prnt(i + 1, j, k);
	}

	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		sc = new StringTokenizer(br.readLine());
		a = nxtCharArr();
		b = nxtCharArr();
		c = nxtCharArr();
		bk = new int[c.length + 1];
		dp = new int[a.length][b.length][c.length];
		build();
		for (int[][] x : dp)
			for (int[] y : x)
				Arrays.fill(y, -1);
		if (solve(0, 0, 0) == 0)
			out.println(0);
		else {
			prnt(0, 0, 0);
			out.println();
		}
		br.close();
		out.close();
	}

	static BufferedReader br;
	static StringTokenizer sc;
	static PrintWriter out;

	static String nxtTok() throws IOException {
		while (!sc.hasMoreTokens()) {
			String s = br.readLine();
			if (s == null)
				return null;
			sc = new StringTokenizer(s.trim());
		}
		return sc.nextToken();
	}

	static int nxtInt() throws IOException {
		return Integer.parseInt(nxtTok());
	}

	static long nxtLng() throws IOException {
		return Long.parseLong(nxtTok());
	}

	static double nxtDbl() throws IOException {
		return Double.parseDouble(nxtTok());
	}

	static int[] nxtIntArr(int n) throws IOException {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nxtInt();
		return a;
	}

	static long[] nxtLngArr(int n) throws IOException {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nxtLng();
		return a;
	}

	static char[] nxtCharArr() throws IOException {
		return nxtTok().toCharArray();
	}
}
