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.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        new Main().run(in, out);
        out.close();
    }


    // dp + kmp
    char[] v;
    char[] a;
    char[] b;
    int an, bn, vn;
    void run(FastScanner in, PrintWriter out) {
        a = in.next().toCharArray();
        b = in.next().toCharArray();
        v = in.next().toCharArray();
        an = a.length;
        bn = b.length;
        vn = v.length;

        kmp = new int[vn];
        kmp();

        dp = new int[an][bn][vn];
        next = new int[an][bn][vn][];

        for (int[][] dd : dp) for (int[] d : dd) Arrays.fill(d, -1);

        go(0, 0, 0);

        if (dp[0][0][0] == 0) {
            out.println(0);
            return;
        }

        int ai = 0, bi = 0, vi = 0;
        StringBuilder sb = new StringBuilder();
        while (ai < an && bi < bn && sb.length() < dp[0][0][0]) {
            int[] n = next[ai][bi][vi];
            if (n[0] == ai+1 && n[1] == bi+1) sb.append(a[ai]);
            ai = n[0];
            bi = n[1];
            vi = n[2];
        }
        out.println(sb.toString());
    }


    int[][][] dp;
    int[][][][] next;

    int go(int ai, int bi, int vi) {

        if (ai == an) return 0;
        if (bi == bn) return 0;

        if (dp[ai][bi][vi] != -1) return dp[ai][bi][vi];

        int max1 = 0;
        int nextvi = 0;
        // can take
        if (a[ai] == b[bi]) {
            if (a[ai] == v[vi]) {
                if (vi != vn-1) {
                    nextvi = vi+1;
                    max1 = 1+go(ai+1, bi+1, nextvi);
                }
            } else {
                if (vi > 0) {
                    nextvi = kmp[vi-1];
                    while (nextvi > 0 && a[ai] != v[nextvi]) nextvi = kmp[nextvi-1];
                    if (a[ai] == v[nextvi]) nextvi++;
                }
                max1 = 1+go(ai+1, bi+1, nextvi);
            }
        }

        int max2 = go(ai+1, bi, vi);
        int max3 = go(ai, bi+1, vi);

        if (max1 >= max2 && max1 >= max3) {
            next[ai][bi][vi] = new int[] {ai+1, bi+1, nextvi};
        } else if (max2 >= max1 && max2 >= max3) {
            next[ai][bi][vi] = new int[] {ai+1, bi, vi};
        } else {
            next[ai][bi][vi] = new int[] {ai, bi+1, vi};
        }

        return dp[ai][bi][vi] = Math.max(max1, Math.max(max2, max3));
    }



    int[] kmp;
    void kmp() {
        for (int i = 1; i < vn; i++) {
            int p = kmp[i-1];
            while (p > 0 && v[i] != v[p]) p = kmp[p-1];
            if (v[i] == v[p]) p++;
            kmp[i] = p;
        }
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            st = null;
        }

        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());
        }
    }
}
