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 LuckyCommonSubsequence {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                System.in));
        char[] s1 = reader.readLine().toCharArray();
        char[] s2 = reader.readLine().toCharArray();
        char[] virus = reader.readLine().toCharArray();
        int l1 = s1.length;
        int l2 = s2.length;
        int l3 = virus.length;
        String tmp = new String(virus);
        int[][] process = new int[l3 + 1][26];
        Arrays.fill(process[l3], l3);
        for (int i = 0; i < l3; i++) {
            for (char c = 'A'; c <= 'Z'; c++) {
                String build = tmp.substring(0, i) + c;
                for (int j = 0; j <= i; j++)
                    if (build.endsWith(tmp.substring(0, j + 1)))
                        process[i][c - 'A'] = j + 1;
            }
        }
        int[][][] dp = new int[l1 + 1][l2 + 1][l3 + 1];
        int[][][] pr = new int[l1 + 1][l2 + 1][l3 + 1];
        for (int[][] fill1 : dp) {
            for (int[] fill2 : fill1) {
                Arrays.fill(fill2, -1);
            }
        }
        for (int[][] fill1 : pr) {
            for (int[] fill2 : fill1) {
                Arrays.fill(fill2, -1);
            }
        }
        dp[0][0][0] = 0;
        for (int i = 0; i <= l1; i++) {
            for (int j = 0; j <= l2; j++) {
                for (int till = 0; till <= l3; till++) {
                    if (dp[i][j][till] != -1) {
                        if (i < l1 && j < l2 && s1[i] == s2[j]) {
                            int nt = process[till][s1[i] - 'A'];
                            if (1 + dp[i][j][till] > dp[i + 1][j + 1][nt]) {
                                dp[i + 1][j + 1][nt] = dp[i][j][till] + 1;
                                pr[i + 1][j + 1][nt] = -till;
                            }
                        }
                        if (i < l1 && dp[i][j][till] > dp[i + 1][j][till]) {
                            dp[i + 1][j][till] = dp[i][j][till];
                            pr[i + 1][j][till] = 1;
                        }
                        if (j < l2 && dp[i][j][till] > dp[i][j + 1][till]) {
                            dp[i][j + 1][till] = dp[i][j][till];
                            pr[i][j + 1][till] = 2;
                        }
                    }
                }
            }
        }
        int p1 = l1;
        int p2 = l2;
        int ss = -1;
        int res = -1;
        for (int i = 0; i < l3; i++) {
            if (dp[l1][l2][i] > res) {
                res = dp[l1][l2][i];
                ss = i;
            }
        }
        if (res <= 0) {
            System.out.println(0);
            return;
        }
        int pp = pr[p1][p2][ss];
        char[] ret = new char[res];
        int at = res - 1;
        while (true) {
            if (pp <= 0) {
                ret[at--] = s1[p1 - 1];
                if (at == -1) {
                    break;
                }
                ss = -pp;
                p1--;
                p2--;
            } else if (pp == 1) {
                p1--;
            } else {
                p2--;
            }
            pp = pr[p1][p2][ss];
        }
        System.out.println(new String(ret));
    }
}