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.util.Arrays;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.File;
import java.io.FilterInputStream;
import java.util.ArrayDeque;
import java.io.InputStream;

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

    static class BLuckyCommonSubsequence {
        final int oo = 987654321;
        strings.AhoCorasick dfa;
        char[] s;
        char[] t;
        int[][][] memo;

        int dp(int si, int ti, int aho) {
            if (dfa.term[aho]) return -oo;
            if (si == s.length || ti == t.length) return 0;
            if (memo[si][ti][aho] != -1) return memo[si][ti][aho];
            int skip = Math.max(dp(si + 1, ti, aho), dp(si, ti + 1, aho));
            int choose = 0;
            if (s[si] == t[ti]) choose = 1 + dp(si + 1, ti + 1, dfa.transition[s[si] - 'A'][aho]);
            return memo[si][ti][aho] = Math.max(choose, skip);
        }

        void bt(int si, int ti, int aho, PrintWriter out) {
            if (si == s.length || ti == t.length || dfa.term[aho]) {
                out.println();
                return;
            }
            int chooseS = dp(si + 1, ti, aho);
            int chooseT = dp(si, ti + 1, aho);
            int skip = Math.max(chooseS, chooseT);
            int choose = 0;
            if (s[si] == t[ti]) choose = 1 + dp(si + 1, ti + 1, dfa.transition[s[si] - 'A'][aho]);
            if (choose > skip) {
                out.print(s[si]);
                bt(si + 1, ti + 1, dfa.transition[s[si] - 'A'][aho], out);
            } else {
                if (chooseS > chooseT) bt(si + 1, ti, aho, out);
                else bt(si, ti + 1, aho, out);
            }
        }

        public void solve(int testNumber, JoltyScanner in, PrintWriter out) {
            s = in.next().toCharArray();
            t = in.next().toCharArray();
            dfa = new strings.AhoCorasick();
            dfa.createAhoCorasick(new String[]{in.next()});
            memo = new int[s.length][t.length][dfa.nodeCount];
            for (int[][] a : memo) for (int[] b : a) Arrays.fill(b, -1);
            if (dp(0, 0, 0) == 0) out.println(0);
            else bt(0, 0, 0, out);
        }

    }

    static class strings {
        public static class AhoCorasick {
            public final int ALPHA = 26;
            public int nodeCount;
            public int[][] transition;
            public boolean[] term;

            public void createAhoCorasick(String[] strs) {
                int maxNodes = 1;
                for (String s : strs) maxNodes += s.length();

                int[][] children = new int[ALPHA][maxNodes];
                boolean[] leaf = new boolean[maxNodes];
                nodeCount = 1;
                for (String s : strs) {
                    int node = 0;
                    for (char ch : s.toCharArray()) {
                        int c = ch - 'A';
                        if (children[c][node] == 0) children[c][node] = nodeCount++;
                        node = children[c][node];
                    }
                    leaf[node] = true;
                }

                transition = new int[ALPHA][nodeCount];
                term = new boolean[nodeCount];

                ArrayDeque<Integer> queue = new ArrayDeque<>();
                queue.add(0);
                queue.add(0);

                while (queue.size() > 0) {
                    int node = queue.remove(), suffLink = queue.remove();

                    term[node] = leaf[node] || term[suffLink];

                    for (int ch = 0; ch < ALPHA; ch++) {
                        if (children[ch][node] != 0) {
                            transition[ch][node] = children[ch][node];
                            queue.add(children[ch][node]);
                            queue.add(node == 0 ? 0 : transition[ch][suffLink]);
                        } else transition[ch][node] = transition[ch][suffLink];
                    }
                }
            }

        }

    }

    static class JoltyScanner {
        public int BS = 1 << 16;
        public char NC = (char) 0;
        public byte[] buf = new byte[BS];
        public int bId = 0;
        public int size = 0;
        public char c = NC;
        public BufferedInputStream in;

        public JoltyScanner(InputStream is) {
            in = new BufferedInputStream(is, BS);
        }

        public JoltyScanner(String s) throws FileNotFoundException {
            in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
        }

        public char nextChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = nextChar();
            while (c > 32) {
                res.append(c);
                c = nextChar();
            }
            return res.toString();
        }

    }
}

