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.*;
import java.util.*;

public class R201_D1_D {
    static String s1;
    static String s2;
    static String virus;
    static int fail[];
    static int dp[][][];
    static int next[][][];

    public static void kmpPreprocess(String t) {
        int i = 0, j = -1;
        int m = t.length();
        fail = new int[m + 1];
        fail[i] = j;
        while (i < m) {
            while (j >= 0 && t.charAt(i) != t.charAt(j)) {
                j = fail[j];
            }
            ++i;
            ++j;
            fail[i] = j;
        }
    }

    public static int get_matched(char curr, int j) {
        while (j >= 0 && curr != virus.charAt(j)) {
            j = fail[j];
        }
        return j + 1;
    }

    public static int call(int index_a, int index_b, int matched) {
        if (matched == virus.length())
            return -1000000;
        if (index_a == s1.length() || index_b == s2.length())
            return 0;
        if (dp[index_a][index_b][matched] != -1)
            return dp[index_a][index_b][matched];
        int res = call(index_a + 1, index_b, matched);
        next[index_a][index_b][matched] = 0;
        int b = call(index_a, index_b + 1, matched);
        if (b > res) {
            res = b;
            next[index_a][index_b][matched] = 1;
        }

        if (s1.charAt(index_a) == s2.charAt(index_b)) {
            int c = 1 + call(index_a + 1, index_b + 1,
                    get_matched(s1.charAt(index_a), matched));
            if (c > res) {
                res = c;
                next[index_a][index_b][matched] = 2;
            }
        }
        return dp[index_a][index_b][matched] = res;
    }

    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);
        s1 = in.readString();
        s2 = in.readString();
        virus = in.readString();
        dp = new int[100][100][100];
        next = new int[100][100][100];

        for (int i = 0; i < dp.length; i++) {
            for (int j = 0; j < dp[i].length; j++) {
                for (int j2 = 0; j2 < dp[i][j].length; j2++) {
                    dp[i][j][j2] = -1;
                }
            }
        }
        kmpPreprocess(virus);
        int len = call(0, 0, 0);
        // System.out.println(len);

        if (len == 0)
            System.out.println(0);
        else {
            String res = "";
            int a = 0, b = 0, c = 0;
            while (res.length() < len) {
                if (next[a][b][c] == 0)
                    a++;
                else if (next[a][b][c] == 1)
                    b++;
                else {
                    res += s1.charAt(a);
                    c = get_matched(s1.charAt(a), c);
                    a++;
                    b++;
                }
            }
            System.out.println(res);
        }
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1000];
        private int curChar, numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private String readLine0() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }

        public String readLine() {
            String s = readLine0();
            while (s.trim().length() == 0)
                s = readLine0();
            return s;
        }

        public String readLine(boolean ignoreEmptyLines) {
            if (ignoreEmptyLines)
                return readLine();
            else
                return readLine0();
        }

        public char readCharacter() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            return (char) c;
        }

        public double readDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, readInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
    }
}