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

public class LuckyCommonSubsequence {
	static char[] a, b, v;
	static int[][][] dp, path;

	static int go(int i, int j, int k) {
		if (k == v.length)
			return -1 << 28;
		if (i == a.length || j == b.length)
			return 0;
		if (dp[i][j][k] != -1)
			return dp[i][j][k];
		int res = -1 << 28;
		if (a[i] == b[j]) {
			int way1 = go(i + 1, j, k);
			int way2 = go(i, j + 1, k);
			int way3 = 1 + go(i + 1, j + 1, failure[k][a[i] - 'A']);
			res = Math.max(res, way3);
			res = Math.max(res, way1);
			res = Math.max(res, way2);
			if (way3 == res)
				path[i][j][k] = 1;
			else if (way1 == res)
				path[i][j][k] = 2;
			else
				path[i][j][k] = 3;
		} else {
			int way1 = go(i + 1, j, k);
			int way2 = go(i, j + 1, k);
			if (way1 > way2)
				path[i][j][k] = 2;
			else
				path[i][j][k] = 3;
			res = Math.max(res, Math.max(way1, way2));
		}
		return dp[i][j][k] = res;
	}

	static int[][] failure;

	public static void main(String[] args) throws Exception {
		InputReader r = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		a = r.next().toCharArray();
		b = r.next().toCharArray();
		v = r.next().toCharArray();
		failure = new int[v.length][26];
		String sub = "";
		for (int i = 0; i < v.length; i++) {
			for (int k = 0; k < 26; k++) {
				String t = sub + (char) (k + 'A');
				String prefix = "";
				for (int j = 0; j < v.length; j++) {
					prefix += v[j];
					if (t.endsWith(prefix))
						failure[i][k] = j + 1;
				}
			}
			sub += v[i];
		}
		dp = new int[101][101][101];
		for (int[][] x : dp)
			for (int[] y : x)
				Arrays.fill(y, -1);
		path = new int[101][101][101];
		int res = go(0, 0, 0);
		if (res <= 0)
			out.println(0);
		else {
			int i = 0, j = 0, k = 0;
			while (i < a.length && j < b.length) {
				if (path[i][j][k] == 1) {
					out.print(a[i]);
					k = failure[k][a[i] - 'A'];
					i++;
					j++;
				} else if (path[i][j][k] == 2) {
					i++;
				} else {
					j++;
				}
			}
			out.println();
		}
		out.close();
	}

	static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}

		public InputReader(FileReader stream) {
			reader = new BufferedReader(stream);
			tokenizer = null;
		}

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				return null;
			}
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}
	}

}
