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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
char s1[110], s2[110], virus[110], ans[110];
int F[110], dp[110][110][110], s1size, s2size, virusSize, ans_i = 0;
void calc_failure_fuction() {
  int k, psize = virusSize;
  F[1] = 0;
  F[0] = 0;
  for (int i = 2; i <= psize; i++) {
    k = F[i - 1];
    while (true) {
      if (virus[k] == virus[i - 1]) {
        F[i] = k + 1;
        break;
      }
      if (k == 0) {
        F[i] = 0;
        break;
      }
      k = F[k];
    }
  }
}
int f(int i, int j, int k) {
  if (k >= virusSize) return -1000;
  if (i >= s1size || j >= s2size) return 0;
  if (dp[i][j][k] != -1) return dp[i][j][k];
  int down = f(i + 1, j, k);
  int right = f(i, j + 1, k);
  int ret = max(right, down);
  if (s1[i] == s2[j]) {
    int tk = k;
    while (tk > 0 && s1[i] != virus[tk]) tk = F[tk];
    if (s1[i] == virus[tk]) {
      tk++;
    }
    ret = max(ret, f(i + 1, j + 1, tk) + 1);
  }
  dp[i][j][k] = ret;
  return ret;
}
void printAnswer(int i, int j, int k) {
  if (k >= virusSize) return;
  if (i >= s1size || j >= s2size) return;
  int valInThisState = f(i, j, k);
  if (valInThisState == f(i + 1, j, k)) {
    printAnswer(i + 1, j, k);
    return;
  }
  if (valInThisState == f(i, j + 1, k)) {
    printAnswer(i, j + 1, k);
    return;
  }
  if (s1[i] == s2[j]) {
    int tk = k;
    while (tk > 0 && s1[i] != virus[tk]) tk = F[tk];
    if (s1[i] == virus[tk]) {
      tk++;
    }
    if (valInThisState == f(i + 1, j + 1, tk) + 1) {
      ans[ans_i++] = s1[i];
      printAnswer(i + 1, j + 1, tk);
    }
  }
  return;
}
int main() {
  scanf("%s\n%s\n%s", s1, s2, virus);
  s1size = strlen(s1), s2size = strlen(s2), virusSize = strlen(virus);
  calc_failure_fuction();
  memset(dp, -1, sizeof dp);
  int f_ans = f(0, 0, 0);
  printAnswer(0, 0, 0);
  if (f_ans > 0)
    printf("%s\n", ans);
  else
    printf("0\n");
  return 0;
}