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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Arrays;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.io.File;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.UnsupportedEncodingException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        LuckyCommonSubsequence solver = new LuckyCommonSubsequence();
        solver.solve(1, in, out);
        out.close();
    }

    static class LuckyCommonSubsequence {
        char[] s;
        char[] t;
        char[] v;
        int[] p;
        int MAX = 110;
        int[][][] dp = new int[MAX][MAX][MAX];
        StringBuilder sb = new StringBuilder();

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

        int rec(int i, int j, int k) {
            if (i == s.length || j == t.length) return 0;
            if (dp[i][j][k] != -1) return dp[i][j][k];
            int ans = rec(i + 1, j, k);
            ans = Math.max(ans, rec(i, j + 1, k)); // don't take anything
            if (s[i] == t[j]) {
                int nxt = getIndex(i, k); // find the next value
                if (nxt >= 0) ans = Math.max(rec(i + 1, j + 1, nxt) + 1, ans);
            }
            return dp[i][j][k] = ans;
        }

        private int getIndex(int curI, int k) {
            while (k > 0 && s[curI] != v[k]) k = p[k - 1];
            if (s[curI] == v[k]) ++k;
            return k == v.length ? -1 : k;
        }

        void build(int i, int j, int k) {
            if (i == s.length || j == t.length)
                return;
            int cur = rec(i, j, k);
            if (rec(i + 1, j, k) == cur) build(i + 1, j, k);
            else if (rec(i, j + 1, k) == cur) build(i, j + 1, k);
            else {
                sb.append(s[i]);
                int nxt = getIndex(i, k);
                build(i + 1, j + 1, nxt);
            }
        }

        public void solve(int testNumber, FastReader in, OutputWriter out) {
            s = in.next().toCharArray();
            t = in.next().toCharArray();
            v = in.next().toCharArray();
            p = prefixFunction(v);
            for (int[][] mat : dp) for (int[] temp : mat) Arrays.fill(temp, -1);
            int ans = rec(0, 0, 0);
            if (ans > 0) {
                build(0, 0, 0);
                out.println(sb);
            } else {
                out.println(0);
            }
        }

    }

    static class FastReader {
        BufferedReader reader;
        StringTokenizer st;

        public FastReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

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

    }

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream os, boolean autoFlush) {
            super(os, autoFlush);
        }

        public OutputWriter(Writer out) {
            super(out);
        }

        public OutputWriter(Writer out, boolean autoFlush) {
            super(out, autoFlush);
        }

        public OutputWriter(String fileName) throws FileNotFoundException {
            super(fileName);
        }

        public OutputWriter(String fileName, String csn) throws FileNotFoundException, UnsupportedEncodingException {
            super(fileName, csn);
        }

        public OutputWriter(File file) throws FileNotFoundException {
            super(file);
        }

        public OutputWriter(File file, String csn) throws FileNotFoundException, UnsupportedEncodingException {
            super(file, csn);
        }

        public OutputWriter(OutputStream out) {
            super(out);
        }


        public void flush() {
            super.flush();
        }


        public void close() {
            super.close();
        }

    }
}

