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.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class BLuckyCommonSubsequence {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s1 = in.next();
            String s2 = in.next();
            String virus = in.next();
            int[] lps = new int[virus.length()];
            for (int i = 1, j = 0; i < virus.length(); ++i) {
                if (virus.charAt(i) == virus.charAt(j)) {
                    j++;
                    lps[i] = j;
                } else {
                    if (j != 0) {
                        j = lps[j - 1];
                        i--;
                    }
                }
            }
            StringBuilder[][][] dp = new StringBuilder[s1.length() + 1][s2.length() + 1][virus.length()];
            for (int i = 0; i <= s1.length(); ++i) {
                dp[i][0][0] = new StringBuilder("");
            }
            for (int j = 0; j <= s2.length(); ++j) {
                dp[0][j][0] = new StringBuilder("");
            }
            for (int i = 1; i <= s1.length(); ++i) {
                for (int j = 1; j <= s2.length(); ++j) {
                    for (int k = 0; k < virus.length(); ++k) {
                        dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k]);
                        dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][k]);
                        if (s1.charAt(i - 1) == s2.charAt(j - 1)) {
                            int cidx = k;
                            while (s1.charAt(i - 1) != virus.charAt(cidx) && cidx != 0)
                                cidx = lps[cidx - 1];
                            if (s1.charAt(i - 1) == virus.charAt(cidx)) {
                                cidx++;
                            }
                            if (cidx != virus.length() && dp[i - 1][j - 1][k] != null) {
                                StringBuilder put = new StringBuilder(dp[i - 1][j - 1][k]);
                                put.append(s1.charAt(i - 1));
                                dp[i][j][cidx] = max(dp[i][j][cidx], put);
                            }
                        }
                    }
                }
            }
            StringBuilder ans = new StringBuilder("");
            for (int i = 0; i < virus.length(); ++i) {
                ans = max(ans, dp[s1.length()][s2.length()][i]);
            }
            if (ans != null && ans.length() != 0) out.print(ans);
            else out.print("0");
        }

        public StringBuilder max(StringBuilder a, StringBuilder b) {
            if (a == null && b == null) return null;
            if (a == null) return b;
            if (b == null) return a;
            if (a.length() > b.length()) return a;
            return b;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

    }
}