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.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Locale;
import java.io.OutputStream;
import java.util.RandomAccess;
import java.io.PrintWriter;
import java.util.AbstractList;
import java.io.Writer;
import java.util.List;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.math.BigInteger;
import java.util.Collections;
import java.io.InputStream;

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

class TaskB {
    private OutputWriter out;

    public void solve(int testNumber, InputReader in, OutputWriter out) {
        this.out = out;
        char[] s1 = ("*" + in.next()).toCharArray();
        char[] s2 = ("*" + in.next()).toCharArray();
        char[] virus = ("*" + in.next()).toCharArray();
        int n = s1.length - 1;
        int m = s2.length - 1;
        int v = virus.length - 1;
        int[][][] dp = new int[n + 1][m + 1][v + 1];
        int[] fail = new int[v + 1];
        for (int t = 1; t <= v; t++) {
            tag:
            for (int s = t - 1; s >= 0; s--) {
                for (int i = 1; i <= s; i++) {
                    if (virus[i] != virus[t - s + i])
                        continue tag;
                }
                fail[t] = s;
                break;
            }
        }
//        System.out.println("fail = " + Arrays.toString(fail));
        //noinspection unchecked
        Tuple4<Integer, Integer, Integer, Character>[][][] pre = new Tuple4[n + 1][m + 1][v + 1];
        ArrayUtils.fill(dp, -1);
        dp[0][0][0] = 0;
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= m; j++) {
                for (int k = 0; k < v; k++) {
                    if (dp[i][j][k] == -1)
                        continue;
                    if (i < n) {
//                        dp[i + 1][j][k] = Math.max(dp[i + 1][j][k], dp[i][j][k]);
                        if (dp[i + 1][j][k] < dp[i][j][k]) {
                            dp[i + 1][j][k] = dp[i][j][k];
                            pre[i + 1][j][k] = TupleUtils.makeTuple(i, j, k, '*');
                        }
                    }
                    if (j < m) {
//                        dp[i][j + 1][k] = Math.max(dp[i][j + 1][k], dp[i][j][k]);
                        if (dp[i][j + 1][k] < dp[i][j][k]) {
                            dp[i][j + 1][k] = dp[i][j][k];
                            pre[i][j + 1][k] = TupleUtils.makeTuple(i, j, k, '*');
                        }
                    }
                    if (i < n && j < m && s1[i + 1] == s2[j + 1]) {
                        if (s1[i + 1] == virus[k + 1]) {
//                            dp[i + 1][j + 1][k + 1] = Math.max(dp[i + 1][j + 1][k + 1],
//                                    dp[i][j][k] + 1);
                            if (dp[i + 1][j + 1][k + 1] < dp[i][j][k] + 1) {
                                dp[i + 1][j + 1][k + 1] = dp[i][j][k] + 1;
                                pre[i + 1][j + 1][k + 1] = TupleUtils.makeTuple(i, j, k, s1[i + 1]);
                            }
                        } else {
//                            dp[i + 1][j + 1][0] = Math.max(dp[i + 1][j + 1][0],
//                                    dp[i][j][k] + 1);
                            int t = k;
                            while (t > 0 && s1[i + 1] != virus[t + 1])
                                t = fail[t];
                            if (s1[i + 1] == virus[t + 1])
                                ++t;
                            if (dp[i + 1][j + 1][t] < dp[i][j][k] + 1) {
                                dp[i + 1][j + 1][t] = dp[i][j][k] + 1;
                                pre[i + 1][j + 1][t] = TupleUtils.makeTuple(i, j, k, s1[i + 1]);
                            }
                        }
                    }
                }
            }
        }
        int answer = 0;
        int k0 = -1;
        for (int k = 0; k < v; k++) {
            if (answer < dp[n][m][k]) {
                answer = dp[n][m][k0 = k];
            }
        }
        if (answer == 0) {
            out.println(0);
        } else {
            printAns(pre, n, m, k0);
            out.println();
        }
    }

    private void printAns(Tuple4<Integer, Integer, Integer, Character>[][][] pre, int i, int j, int k) {
        if (pre[i][j][k] == null) {
            return;
        }
        Tuple4<Integer, Integer, Integer, Character> cur = pre[i][j][k];
        printAns(pre, cur._1, cur._2, cur._3);
        if (cur._4 != '*') {
            out.print(cur._4);
        }
    }
}

class OutputWriter {
    private PrintWriter writer;

    public OutputWriter(OutputStream stream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void println(int i) {
        writer.println(i);
    }

    public void print(Object obj) {
        writer.print(obj);
    }

    public void println() {
        writer.println();
    }

    public void close() {
        writer.close();
    }

    }

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1 << 16];
    private int curChar;
    private int numChars;

    public InputReader(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 static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    }

class Tuple4<A, B, C, D> implements Comparable<Tuple4<A, B, C, D>> {
    public final A _1;
    public final B _2;
    public final C _3;
    public final D _4;

    public Tuple4(A _1, B _2, C _3, D _4) {
        this._1 = _1;
        this._2 = _2;
        this._3 = _3;
        this._4 = _4;
    }

    public int compareTo(Tuple4<A, B, C, D> o) {
        int tmp;
        //noinspection unchecked
        if ((tmp = (((Comparable<A>) _1).compareTo(o._1))) != 0) return tmp;
        //noinspection unchecked
        if ((tmp = (((Comparable<B>) _2).compareTo(o._2))) != 0) return tmp;
        //noinspection unchecked
        if ((tmp = (((Comparable<C>) _3).compareTo(o._3))) != 0) return tmp;
        //noinspection unchecked
        if ((tmp = (((Comparable<D>) _4).compareTo(o._4))) != 0) return tmp;
        return tmp;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Tuple4 tuple4 = (Tuple4) o;

        if (_1 != null ? !_1.equals(tuple4._1) : tuple4._1 != null) return false;
        if (_2 != null ? !_2.equals(tuple4._2) : tuple4._2 != null) return false;
        if (_3 != null ? !_3.equals(tuple4._3) : tuple4._3 != null) return false;
        if (_4 != null ? !_4.equals(tuple4._4) : tuple4._4 != null) return false;

        return true;
    }

    public int hashCode() {
        int result = _1 != null ? _1.hashCode() : 0;
        result = 31 * result + (_2 != null ? _2.hashCode() : 0);
        result = 31 * result + (_3 != null ? _3.hashCode() : 0);
        result = 31 * result + (_4 != null ? _4.hashCode() : 0);
        return result;
    }

    public String toString() {
        return "(" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ")";
    }
}

class ArrayUtils {



    public static void fill(int[][] array, int val) {
        for (int[] subArray : array) {
            Arrays.fill(subArray, val);
        }
    }

    public static void fill(int[][][] array, int val) {
        for (int[][] subArray : array) {
            ArrayUtils.fill(subArray, val);
        }
    }



    }

class TupleUtils {

    public static <A, B, C, D> Tuple4<A, B, C, D> makeTuple(A _1, B _2, C _3, D _4) {
        return new Tuple4<A, B, C, D>(_1, _2, _3, _4);
    }

    }