Problem: 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

Solution (in JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.util.Stack;
import java.io.InputStream;

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

    static class B_LUCKYCOMMONSUBSEQUENCES {
        void LPS(char[] pat, int M, int lps[]) {
            int len = 0;
            int i = 1;
            lps[0] = 0;
            while (i < M) {
                if (pat[(i)] == pat[(len)]) {
                    len++;
                    lps[i] = len;
                    i++;
                } else {
                    if (len != 0) {
                        len = lps[len - 1];
                    } else {
                        lps[i] = len;
                        i++;
                    }
                }
            }
        }

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            char[] a = in.scanString().toCharArray();
            char[] b = in.scanString().toCharArray();
            char[] c = in.scanString().toCharArray();
            int[][][] dp = new int[a.length + 1][b.length + 1][c.length];
            int[][][] where = new int[a.length + 1][b.length + 1][c.length];
            for (int i = 0; i <= a.length; i++) {
                for (int j = 0; j <= b.length; j++) {
                    for (int k = 0; k < c.length; k++) {
                        dp[i][j][k] = Integer.MIN_VALUE / 3;
                        where[i][j][k] = -1;
                    }
                }
            }
            dp[0][0][0] = 0;
            int[] lps = new int[c.length];
            LPS(c, c.length, lps);
            for (int i = 0; i <= a.length; i++) {
                for (int j = 0; j <= b.length; j++) {
                    for (int k = 0; k < c.length; k++) {
                        if (dp[i][j][k] >= 0) {
                            if (i + 1 <= a.length) {
                                if (dp[i + 1][j][k] < dp[i][j][k]) {
                                    dp[i + 1][j][k] = dp[i][j][k];
                                    where[i + 1][j][k] = 1;
                                }
                            }
                            if (j + 1 <= b.length) {
                                if (dp[i][j + 1][k] < dp[i][j][k]) {
                                    dp[i][j + 1][k] = dp[i][j][k];
                                    where[i][j + 1][k] = 2;
                                }
                            }
                            if ((i + 1 <= a.length && j + 1 <= b.length && a[i] == b[j])) {
                                int temp = k;
                                while (true) {
                                    if (c[temp] == a[i]) {
                                        temp++;
                                        break;
                                    }
                                    if (temp == 0) break;
                                    temp = lps[temp - 1];
                                }
                                if (temp < c.length) {
                                    if (dp[i + 1][j + 1][temp] < dp[i][j][k] + 1) {
                                        dp[i + 1][j + 1][temp] = dp[i][j][k] + 1;
                                        where[i + 1][j + 1][temp] = 3 + k;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            int which_k = -1;
            int max = -1;
            for (int i = 0; i < c.length; i++) {
                if (dp[a.length][b.length][i] > max) {
                    max = dp[a.length][b.length][i];
                    which_k = i;
                }
            }
            if (which_k == -1 || max <= 0) {
                out.println(0);
                return;
            }
            Stack<Character> st = new Stack<>();
            int ii = a.length;
            int jj = b.length;
            while (ii > 0 && jj > 0) {
                if (where[ii][jj][which_k] == 1) {
                    ii--;
                } else if (where[ii][jj][which_k] == 2) {
                    jj--;
                } else {
                    which_k = where[ii][jj][which_k] - 3;
                    ii--;
                    jj--;
                    st.push(a[ii]);
                }
            }
            while (!st.empty()) {
                out.print(st.pop());
            }
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public String scanString() {
            int c = scan();
            if (c == -1) return null;
            while (isWhiteSpace(c)) c = scan();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = scan();
            } while (!isWhiteSpace(c));
            return res.toString();
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}