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.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "KharYusuf", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastReader in = new FastReader(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, FastReader s, PrintWriter w) {
            char[] s1 = s.next().toCharArray(), s2 = s.next().toCharArray();
            char[] v = s.next().toCharArray();
            int n1 = s1.length, n2 = s2.length, m = v.length;
            int[][][] dp = new int[n1 + 1][n2 + 1][m + 1];
            dp[0][0][0] = 0;
            dist[][][] prev = new dist[n1 + 1][n2 + 1][m + 1];
            for (int i = 1; i <= n1; i++)
                for (int j = 1; j <= n2; j++) {
                    if (s1[i - 1] == s2[j - 1]) {
                        for (int k = 1; k <= m; k++) {
                            int ind = largestPrefix(s1[i - 1], k, v);
                            //if (n1 == 10 && i == 8 && j == 10) w.println(ind + " " + k);
                            if (dp[i][j][ind] < dp[i - 1][j - 1][k - 1] + 1) {
                                dp[i][j][ind] = dp[i - 1][j - 1][k - 1] + 1;
                                prev[i][j][ind] = new dist(i - 1, j - 1, k - 1);
                            }
                        }
                    }
                    for (int k = 0; k < m; k++) {
                        if (dp[i][j][k] < dp[i][j - 1][k]) {
                            dp[i][j][k] = dp[i][j - 1][k];
                            prev[i][j][k] = new dist(i, j - 1, k);
                        }
                        if (dp[i][j][k] < dp[i - 1][j][k]) {
                            dp[i][j][k] = dp[i - 1][j][k];
                            prev[i][j][k] = new dist(i - 1, j, k);
                        }
                    }
                }
            int ans = 0, ind = -1;
            for (int i = 0; i < m; i++)
                if (ans < dp[n1][n2][i]) {
                    ans = dp[n1][n2][i];
                    ind = i;
                }
            if (ans == 0) {
                w.println(0);
                return;
            }
            char[] res = new char[ans];
            int ptr1 = n1, ptr2 = n2, ptr = ans - 1;
        /*if (n1 == 10) for (int i = 0; i <= n1; i++) {
            for (int j = 0; j <= m; j++) w.print(dp[i][i][j] + " ");
            w.println();
        }*/
            while (prev[ptr1][ptr2][ind] != null) {
                int t1 = ptr1, t2 = ptr2, t3 = ind;
                ptr1 = prev[t1][t2][t3].x;
                ptr2 = prev[t1][t2][t3].y;
                ind = prev[t1][t2][t3].z;
                if (dp[t1][t2][t3] > dp[ptr1][ptr2][ind]) res[ptr--] = s1[ptr1];
            }
            w.println(res);
        }

        int largestPrefix(char c, int to, char[] v) {
            int ans = 0;
            for (int i = 0; i < to; i++) {
                if (v[to - i - 1] == c && check(i, to - 1, v)) {
                    ans = to - i;
                    break;
                }
            }
            return ans;
        }

        boolean check(int s1, int e1, char[] v) {
            for (int i = s1, j = 0; i < e1; i++, j++) if (v[i] != v[j]) return false;
            return true;
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

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

        public 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 String next() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class dist implements Comparable<dist> {
        public int x;
        public int y;
        public int z;

        public dist(int xi, int yi, int zi) {
            x = xi;
            y = yi;
            z = zi;
        }

        public int compareTo(dist other) {
            if (this.z > other.z) {
                return 1;
            }
            if (this.z < other.z) {
                return -1;
            }
            return 0;
        }

    }
}