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;
const int N = 100 + 10;
const int inf = (int)1e9;
int dp[N][N][N];
char first[N], second[N], virus[N];
int la, lb, lv;
int lps[N], dp_kmp[250][N];
void cal_lps() {
  int indx = 0, len = lv;
  lps[0] = 0;
  for (int i = 1; i < len;) {
    if (virus[i] == virus[indx]) {
      lps[i] = indx + 1;
      i++, indx++;
    } else {
      if (indx != 0)
        indx = lps[indx - 1];
      else {
        lps[i] = 0;
        i++;
      }
    }
  }
}
int solve(char ch, int indx) {
  int &ret = dp_kmp[ch][indx];
  if (ret != -1) return ret;
  while (indx > 0 && virus[indx] != ch) {
    indx = lps[indx - 1];
  }
  if (virus[indx] == ch) indx++;
  return ret = indx;
}
int rec(int i, int j, int k) {
  if (i == la || j == lb) return dp[i][j][k] = 0;
  int &ret = dp[i][j][k];
  if (ret != -1) return ret;
  ret = 0;
  if (first[i] == second[j]) {
    int tmp = solve(first[i], k);
    if (tmp < lv) {
      ret = max(ret, 1 + rec(i + 1, j + 1, tmp));
    }
  }
  ret = max(ret, rec(i + 1, j, k));
  ret = max(ret, rec(i, j + 1, k));
  return ret;
}
void Path(int i, int j, int k) {
  if (i == la || j == lb) return;
  int nw = dp[i][j][k];
  if (nw == dp[i + 1][j][k]) return Path(i + 1, j, k);
  if (nw == dp[i][j + 1][k]) return Path(i, j + 1, k);
  printf("%c", first[i]);
  return Path(i + 1, j + 1, solve(first[i], k));
}
int main() {
  scanf("%s", &first);
  scanf("%s", &second);
  scanf("%s", &virus);
  la = strlen(first);
  lb = strlen(second);
  lv = strlen(virus);
  memset(dp, -1, sizeof(dp));
  memset(dp_kmp, -1, sizeof(dp_kmp));
  cal_lps();
  int ans = rec(0, 0, 0);
  if (ans > 0)
    Path(0, 0, 0);
  else
    printf("0");
  printf("\n");
  return 0;
}