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.*;
import java.math.BigInteger;
import java.util.*;
import static java.util.Arrays.*;

public class B {
	private static final int mod = (int)1e9+9;

	final IOFast io = new IOFast();

	int[][][] dp = new int[101][101][101];
	char[] a, b, c;
	char[][][][] ans = new char[101][101][101][];
	
	int next(int p, char ch) {
//		if(c[p] == ch) return p - 1;
		int p0 = p + 1;
		for(; p < c.length; p++) if(c[p] == ch) {
			boolean ok = true;
			for(int i = p + 1; i < c.length; i++) {
				if(c[i] != c[p0 + i - p - 1]) {
					ok = false;
					break;
				}
			}
			if(ok) {
				return p;
			}
		}
		return p;
	}
	
	int rec(int x, int y, int z) {
		if(x < 0 || y < 0 || z <= 0) return -10000;
		if(x == 0 || y == 0) return 0;
		if(dp[x][y][z] != -1) return dp[x][y][z];

		int ax = -2, ay = -2, az = -2;
		int v0 = -10000, v1, v2;
		if(a[x-1] == b[y-1]) {
			ax = x - 1;
			ay = y - 1;
			az = next(z - 1, a[x - 1]);
			v0 = rec(x - 1, y - 1, az);
			v0++;
		}
		v1 = rec(x - 1, y, z);
		v2 = rec(x, y - 1, z);
		
		if(v1 >= v0 && v1 >= v2) {
			ax = x - 1;
			ay = y;
			az = z;
		}
		else if(v2 >= v0 && v2 >= v1) {
			ax = x;
			ay = y - 1;
			az = z;
		}
		
		if(Math.max(Math.max(v0, v1), v2) <= 0) {
			return dp[x][y][z] = 0;
		}
		dp[x][y][z] = Math.max(Math.max(v0, v1), v2);

		if(ans[ax][ay][az] == null || dp[x][y][z] == ans[ax][ay][az].length + 1) {
			ans[x][y][z] = new char[dp[x][y][z]];
			for(int i = 0; ans[ax][ay][az] != null && i < ans[ax][ay][az].length; i++) {
				ans[x][y][z][i] = ans[ax][ay][az][i];
			}
			ans[x][y][z][ans[x][y][z].length - 1] = a[x-1];
		}
		else {
			ans[x][y][z] = ans[ax][ay][az];
		}
//		System.err.println(x + " " + y + " " + z + " " + dp[x][y][z] + " " + a[x-1] + " " + b[y-1] + " " + ans[ax][ay][az] + " " + Arrays.toString(ans[x][y][z]));
		return dp[x][y][z];
	}
	
	public void run() throws IOException {
		for(int[][] d : dp) for(int[] p : d) Arrays.fill(p, -1);
		a = io.next();
		b = io.next();
		c = io.next();
		if(rec(a.length, b.length, c.length) <= 0) {
			io.out.println(0);
		}
		else {
			io.out.println(new String(ans[a.length][b.length][c.length]));
		}
	}

	
	void main() throws IOException {
		//		IOFast.setFileIO("rle-size.in", "rle-size.out");
		try {
			run();
		}
		catch (EndOfFileRuntimeException e) { }
		io.out.flush();
	}

	public static void main(String[] args) throws IOException {
		new B().main();
	}
	
	static class EndOfFileRuntimeException extends RuntimeException {
		private static final long serialVersionUID = -8565341110209207657L; }

	static
	public class IOFast {
		private BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		private PrintWriter out = new PrintWriter(System.out);

		void setFileIO(String ins, String outs) throws IOException {
			in = new BufferedReader(new FileReader(ins));
			out = new PrintWriter(new FileWriter(outs));
		}

		//		private static final int BUFFER_SIZE = 50 * 200000;
		private static int pos, readLen;
		private static final char[] buffer = new char[1024 * 8];
		private static final char[] str = new char[500000*8*2];
		private static boolean[] isDigit = new boolean[256];
		private static boolean[] isSpace = new boolean[256];
		private static boolean[] isLineSep = new boolean[256];

		static {
			for(int i = 0; i < 10; i++) { isDigit['0' + i] = true; }
			isDigit['-'] = true;
			isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true;
			isLineSep['\r'] = isLineSep['\n'] = true;
		}

		public int read() throws IOException {
			if(pos >= readLen) {
				pos = 0;
				readLen = in.read(buffer);
				if(readLen <= 0) { throw new EndOfFileRuntimeException(); }
			}
			return buffer[pos++];
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(nextString());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(nextString());
		}

		public char nextChar() throws IOException {
			while(true) {
				final int c = read();
				if(!isSpace[c]) { return (char)c; }
			}
		}
		
		int reads(char[] cs, int len, boolean[] accept) throws IOException {
			try {
				while(true) {
					final int c = read();
					if(accept[c]) { break; }
					str[len++] = (char)c;
				}
			}
			catch(EndOfFileRuntimeException e) { ; }
			
			return len;
		}

		public char[] nextLine() throws IOException {
			int len = 0;
			str[len++] = nextChar();
			len = reads(str, len, isLineSep);
			
			try {
				if(str[len-1] == '\r') { len--; read(); }
			}
			catch(EndOfFileRuntimeException e) { ; }
			
			return Arrays.copyOf(str, len);
		}

		public String nextString() throws IOException {
			return new String(next());
		}

		public char[] next() throws IOException {
			int len = 0;
			str[len++] = nextChar();
			len = reads(str, len, isSpace);
			return Arrays.copyOf(str, len);
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(nextString());
		}

	}

}
