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.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class B3 {

    static final int INF = (int) 1e9;

    public static void main(String[] args) {
        var scanner = new BufferedScanner();
        var writer = new PrintWriter(new BufferedOutputStream(System.out));

        var t = 1;//scanner.nextInt();
        for (int tc = 0; tc < t; tc++) {
            String s1 = scanner.next();
            String s2 = scanner.next();
            String virus = scanner.next();
            var solver = new Solver(s1, s2, virus);
            var ans = solver.solve();
            if (ans.isEmpty()) {
                writer.println(0);
            } else {
                writer.println(ans);
            }
        }

        scanner.close();
        writer.flush();
        writer.close();
    }

    static class Solver {
        String s1, s2, virus;
        int[][][] cache, next;
        int[] prefix;

        Solver(String s1, String s2, String virus) {
            this.s1 = s1;
            this.s2 = s2;
            this.virus = virus;
        }

        String solve() {
            cache = new int[101][101][101];
            next = new int[101][101][101];
            for (int i = 0; i < s1.length(); i++) {
                for (int j = 0; j < s2.length(); j++) {
                    Arrays.fill(cache[i][j], -INF);
                    Arrays.fill(next[i][j], -INF);
                }
            }
            prefix = prefixFunction(virus.toCharArray());
//            {
//                System.out.print("prefix: ");
//                for (var i : prefix) {
//                    System.out.print(i + " ");
//                }
//                System.out.println();
//            }
            var ans = dfs(0, 0, 0);
//            System.out.println("ans=" + ans);
            int i = 0, j = 0, k = 0;
            var sb = new StringBuilder();
            while (i < s1.length() && j < s2.length() && cache[i][j][k] > 0) {
//                System.out.println(i + " " + j + " " + k + " " + cache[i][j][k] + " " + next[i][j][k]);
                if (next[i][j][k] == 1) {
                    i++;
                } else if (next[i][j][k] == 2) {
                    j++;
                } else {
//                    System.out.println(s1.charAt(i) + " " + s2.charAt(j));
                    sb.append(s1.charAt(i));
                    k = -next[i][j][k];
                    i++;
                    j++;
                }
            }
            return sb.toString();
        }

        static int[] prefixFunction(char[] s) {
            var ans = new int[s.length];
            for (int i = 1; i < s.length; i++) {
                var k = ans[i - 1];
                while (k > 0 && s[i] != s[k]) {
                    k = ans[k - 1];
                }
                if (s[i] == s[k]) {
                    ans[i] = k + 1;
                }
            }
            return ans;
        }

        int dfs(int i, int j, int k) {
            if (k == virus.length()) { // already contains virus, not applicable
                return -INF;
            }
            if (i == s1.length() || j == s2.length()) {  // one string is already exhausted, no more possible
                return 0;
            }
            if (cache[i][j][k] != -INF) {
                return cache[i][j][k];
            }
            int ans1, ans2;
            int ans = Math.max(ans1 = dfs(i + 1, j, k), ans2 = dfs(i, j + 1, k));
            if (ans > 0) {
                if (ans == ans1) {
                    next[i][j][k] = 1;
                } else {
                    next[i][j][k] = 2;
                }
            }
            char c1 = s1.charAt(i);
            char c2 = s2.charAt(j);
            if (c1 == c2) {
                int k1 = k;
                while (k1 > 0 && c1 != virus.charAt(k1)) {
                    k1 = prefix[k1 - 1];
                }
                if (c1 == virus.charAt(k1)) {
                    k1++;
                }
                int ans4;
                ans = Math.max(ans, ans4 = dfs(i + 1, j + 1, k1) + 1);
                if (ans > 0 && ans == ans4) {
                    next[i][j][k] = -k1;
                }
            }
            cache[i][j][k] = ans;
            return ans;
        }
    }

    public static class BufferedScanner {
        BufferedReader br;
        StringTokenizer st;

        public BufferedScanner(Reader reader) {
            br = new BufferedReader(reader);
        }

        public BufferedScanner() {
            this(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }

    static long gcd(long a, long b) {
        if (a < b) {
            return gcd(b, a);
        }
        while (b > 0) {
            long tmp = b;
            b = a % b;
            a = tmp;
        }
        return a;
    }

    static long inverse(long a, long m) {
        long[] ans = extgcd(a, m);
        return ans[0] == 1 ? (ans[1] + m) % m : -1;
    }

    private static long[] extgcd(long a, long m) {
        if (m == 0) {
            return new long[]{a, 1, 0};
        } else {
            long[] ans = extgcd(m, a % m);
            long tmp = ans[1];
            ans[1] = ans[2];
            ans[2] = tmp;
            ans[2] -= ans[1] * (a / m);
            return ans;
        }
    }

    private static List<Integer> primes(double upperBound) {
        var limit = (int) Math.sqrt(upperBound);
        var isComposite = new boolean[limit + 1];
        var primes = new ArrayList<Integer>();
        for (int i = 2; i <= limit; i++) {
            if (isComposite[i]) {
                continue;
            }
            primes.add(i);
            int j = i + i;
            while (j <= limit) {
                isComposite[j] = true;
                j += i;
            }
        }
        return primes;
    }


}