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

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

class TaskB {
    public void solve(int testNumber, FastScanner in, PrintWriter out) {
        char[] s1 = in.next().toCharArray();
        char[] s2 = in.next().toCharArray();
        String virStr = in.next();
        char[] virus = virStr.toCharArray();
        int[][] nextPrefix = new int[virus.length][26];
        for (int k = 0; k < virus.length; k++) {
            for (int c = 0; c < 26; c++) {
                char ch = (char)(c + 'A');
                String s = virStr.substring(0, k) + ch;
                while (!virStr.startsWith(s)) {
                    s = s.substring(1);
                }
                nextPrefix[k][c] = s.length();
            }
        }
        int[][][] d = new int[s1.length + 1][s2.length + 1][virus.length];
        Prev[][][] prev = new Prev[s1.length + 1][s2.length + 1][virus.length];
        for (int i = 0; i <= s1.length; i++) {
            for (int j = 0; j <= s2.length; j++) {
                for (int k = 0; k < virus.length; k++) {
                    if (i < s1.length && j < s2.length && s1[i] == s2[j]) {
                        int nk = nextPrefix[k][s1[i] - 'A'];
                        if (nk < virus.length && d[i + 1][j + 1][nk] < 1 + d[i][j][k]) {
                            d[i + 1][j + 1][nk] = 1 + d[i][j][k];
                            prev[i + 1][j + 1][nk] = new Prev(i, j, k, s1[i]);
                        }
                    }
                    if (i < s1.length && d[i + 1][j][k] < d[i][j][k]) {
                        d[i + 1][j][k] = d[i][j][k];
                        prev[i + 1][j][k] = prev[i][j][k];
                    }
                    if (j < s2.length && d[i][j + 1][k] < d[i][j][k]) {
                        d[i][j + 1][k] = d[i][j][k];
                        prev[i][j + 1][k] = prev[i][j][k];
                    }
                }
            }
        }
        int bestK = 0;
        for (int k = 0; k < virus.length; k++) {
            if (d[s1.length][s2.length][k] > d[s1.length][s2.length][bestK]) {
                bestK = k;
            }
        }
        int len = d[s1.length][s2.length][bestK];
        if (len == 0) {
            out.println(0);
            return;
        }
        char[] res = new char[len];
        {
            int i = s1.length;
            int j = s2.length;
            int k = bestK;
            for (int step = len - 1; step >= 0; step--) {
                Prev pr = prev[i][j][k];
                res[step] = pr.ch;
                i = pr.i;
                j = pr.j;
                k = pr.k;
            }
        }
        out.println(new String(res));
    }

    class Prev {
        int i, j, k;
        char ch;

        Prev(int i, int j, int k, char ch) {
            this.i = i;
            this.j = j;
            this.k = k;
            this.ch = ch;
        }
    }
}

class FastScanner {

    private BufferedReader in;
    private StringTokenizer st;

    public FastScanner(InputStream stream) {
        in = new BufferedReader(new InputStreamReader(stream));
    }

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

    }