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:
//package com.company;
import java.io.*;
import java.lang.*;
import java.util.*;
public class Main {
    private static String s1;
    private static String s2;
    private static String s3;
    public static Scanner sc = new Scanner();
    public static PrintWriter pw = new PrintWriter(System.out);
    public static boolean[][][] vis = new boolean[102][102][102];
    public static int[][][] dp = new int[102][102][102];
    public static ArrayList<Integer> KMP = new ArrayList<>();
    public static int solve(int p1,int p2,int p3)
    {
        if (p3>=s3.length()) return (int) -1e9;
        if (p1>=s1.length()||p2>=s2.length()) return 0;
        int ret = dp[p1][p2][p3];
        if (vis[p1][p2][p3])  return ret;
        vis[p1][p2][p3]=true;
        ret=0;
        ret=Math.max(ret,solve(p1+1,p2,p3));
        ret=Math.max(ret,solve(p1,p2+1,p3));
        if (s1.charAt(p1)==s2.charAt(p2))
        {
            if (s1.charAt(p1)==s3.charAt(p3))
                ret=Math.max(ret,solve(p1+1,p2+1,p3+1)+1);
            else {
                int k=KMP.get((p3>0?p3-1:p3));
                while(k>0&&s3.charAt(k)!=s2.charAt(p2))
                    k = KMP.get(k - 1);
                if (s3.charAt(k)==s2.charAt(p2)) ++k;
                ret=Math.max(ret,solve(p1+1,p2+1,k)+1);
            }
        }
        dp[p1][p2][p3]=ret;
        return ret;
    }
    public static void out(int p1,int p2,int p3)
    {
        if (p3>=s3.length()) return;
        if (p1>=s1.length()||p2>=s2.length()) return;
        int ret = dp[p1][p2][p3];
        if (ret==solve(p1+1,p2,p3))
        {
            out(p1+1,p2,p3);
            return;
        }
        if (ret==solve(p1,p2+1,p3))
        {
            out(p1,p2+1,p3);
            return;
        }
        if (s1.charAt(p1)==s2.charAt(p2))
        {
            if (s1.charAt(p1)==s3.charAt(p3))
            {
                if (ret==solve(p1+1,p2+1,p3+1)+1){
                    pw.print(s1.charAt(p1));
                    out(p1+1,p2+1,p3+1);
                    return;
                }
            }
            else {
                int k=KMP.get((p3>0?p3-1:p3));
                while(k>0&&s3.charAt(k)!=s2.charAt(p2))
                    k = KMP.get(k - 1);
                if (s3.charAt(k)==s2.charAt(p2)) ++k;
                if (ret==solve(p1+1,p2+1,k)+1){
                    pw.print(s1.charAt(p1));
                    out(p1+1,p2+1,k);
                    return;
                }
            }
        }
    }
    public static ArrayList<Integer> compute(String pat)
    {
        int m = pat.length();
        ArrayList<Integer> longestPrefix = new ArrayList<>();
        for (int i=0;i<m;++i)
            longestPrefix.add(0);
        for (int i=1,k=0;i<m;++i)
        {
            while(k>0&&pat.charAt(k)!=pat.charAt(i))
                k = longestPrefix.get(k - 1);
            if (pat.charAt(k)==pat.charAt(i))
                longestPrefix.set(i, ++k);
            else
                longestPrefix.set(i, k);
        }
        return longestPrefix;
    }
    public static void main(String[] args) throws Throwable {

        s1=sc.next();
        s2=sc.next();
        s3 = sc.next();
        KMP=compute(s3);
        int ans=solve(0,0,0);
        if (ans==0) pw.println(0);
        else out(0,0,0);
        pw.close();
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        Scanner(String s) throws Throwable {
            br = new BufferedReader(new FileReader(new File(s)));
        }

        String next() throws Throwable {
            if (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        int nextInt() throws Throwable {
            return Integer.parseInt(next());
        }

        long nextLong() throws Throwable {
            return Long.parseLong(next());
        }

    }
}