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
// package CF;

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 D {
	static int memo [][][][];
	static char [] s,t,v;
	static int [] p, fail[];
	static int INF = 20000;
	static int dp(int s1, int v1, int s2, int v2){
//		System.out.println(s1 + " " + v1 + " " + s2 + " " + v2);
		if(v1 == v.length || v2 == v.length)
			return -INF;
		if(s1 == s.length || s2 == t.length)
			return 0;
		if(memo[s1][v1][s2][v2] != -1)
			return memo[s1][v1][s2][v2];
		int ans = 0;
		if(s[s1] == t[s2]){
			ans = Math.max(ans, 1 + dp(s1+1, fail[v1][s[s1]-'A'], s2+1, fail[v2][t[s2]-'A']));
		}
		ans = Math.max(ans, Math.max(dp(s1+1, v1, s2, v2), dp(s1, v1, s2+1, v2)));
//		System.out.println(s1 + " " + v1 + " " + s2 + " " + v2 + " "+ ans);
		return memo[s1][v1][s2][v2] = ans;
	}
	static StringBuilder sb;
	static void print(int s1, int v1, int s2, int v2){
		if(s1 == s.length || s2 == t.length)
			return;
		int opt = dp(s1, v1, s2, v2);
		if(s[s1] == t[s2]){
			if(opt == 1 + dp(s1+1, fail[v1][s[s1]-'A'], s2+1, fail[v2][t[s2]-'A'])){
				sb.append(s[s1]);
				print(s1+1, fail[v1][s[s1]-'A'], s2+1, fail[v2][t[s2]-'A']);
				return;
			}
		}
		if(opt == dp(s1+1, v1, s2, v2)) 
			 print(s1+1, v1, s2, v2);
		else print(s1, v1, s2+1, v2);
	}
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		s = sc.next().toCharArray();
		t = sc.next().toCharArray();
		v = sc.next().toCharArray();
		memo = new int[101][101][101][101];
		for(int [][][]i:memo)
			for(int [][]j:i)
				for(int []k:j)
					Arrays.fill(k, -1);
		p = prefixFunction(v);
//		System.out.println(Arrays.toString(p));
		fail = new int[p.length][26];
		for (int i = 0; i < fail.length; i++) {
			for (int j = 0; j < 26; j++) {
				int po = i;
				while(po > 0 && j != v[po]-'A'){
					po = p[po-1];
				}
				fail[i][j] = j != v[po]-'A'?po:po+1;
			}
		}
		if(dp(0, 0, 0, 0) == 0)
		{
			System.out.println(0);
			return;
		}
		sb = new StringBuilder();
		print(0, 0, 0, 0);
		out.println(sb);
		out.flush();
		out.close();
	}
	
	static int[] prefixFunction(char[] s)		// O(n)
	{
		int n = s.length, pi[] = new int[n];
		for(int i = 1, j = 0; i < n; ++i)		//j = pi[i-1] at the beginning of every iteration
		{
			while(j > 0 && s[i] != s[j])
				j = pi[j-1];
			if(s[i] == s[j])
				++j;
			pi[i] = j;
		}
		return pi;
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}