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 SIZE = 128;
char astr[SIZE], bstr[SIZE], img[SIZE];
int n, m, k;
int pref[SIZE];
int res[SIZE][SIZE][SIZE];
int father[SIZE][SIZE][SIZE];
void relax(int &xres, int &xf, int nres, int nf) {
  if (xres < nres) {
    xres = nres;
    xf = nf;
  }
}
int main() {
  scanf("%s%s%s", astr, bstr, img);
  n = strlen(astr);
  m = strlen(bstr);
  k = strlen(img);
  pref[0] = 0;
  {
    int i = 1, j = 0;
    while (i < k) {
      if (img[i] == img[j]) {
        i++;
        j++;
        pref[i] = j;
      } else {
        if (j == 0) {
          i++;
          pref[i] = 0;
        } else
          j = pref[j];
      }
    }
  }
  memset(res, -63, sizeof(res));
  memset(father, -63, sizeof(father));
  res[0][0][0] = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      for (int u = 0; u < k; u++) {
        int tres = res[i][j][u];
        if (tres < 0) continue;
        if (i < n) relax(res[i + 1][j][u], father[i + 1][j][u], tres, -1);
        if (j < m) relax(res[i][j + 1][u], father[i][j + 1][u], tres, -2);
        if (astr[i] == bstr[j]) {
          char c = astr[i];
          int v = u;
          while (v > 0 && c != img[v]) v = pref[v];
          if (c == img[v]) v++;
          if (v == k) continue;
          relax(res[i + 1][j + 1][v], father[i + 1][j + 1][v], tres + 1, u);
        }
      }
  int ans = -1;
  int best = -1;
  for (int u = 0; u < k; u++) relax(ans, best, res[n][m][u], u);
  string word;
  int i = n, j = m, u = best;
  while (i + j > 0) {
    int ff = father[i][j][u];
    if (ff == -1)
      i--;
    else if (ff == -2)
      j--;
    else {
      i--;
      j--;
      u = ff;
      assert(astr[i] == bstr[j]);
      word += astr[i];
    }
  }
  reverse(word.begin(), word.end());
  printf("%s\n", word.empty() ? "0" : word.c_str());
  return 0;
}