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 nmax = 101;
const int oo = 1000000000;
string a, b, c;
int n, m, p;
int F[nmax][nmax][nmax];
int T[nmax][nmax][nmax];
int ne[nmax];
int ans;
int cs_luu;
char kq[nmax];
int buoc1() {
  ne[1] = 0;
  ne[0] = 0;
  int j = 0;
  for (int i = 2; i <= p; i++) {
    while (j > 0 && (c[i - 1] != c[j])) j = ne[j];
    if (c[i - 1] == c[j]) j++;
    ne[i] = j;
  }
  return 0;
}
int cs[nmax];
int buoc2() {
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) {
      if (a[i - 1] != b[j - 1]) {
        for (int k = 0; k <= p - 1; k++) {
          F[i][j][k] = max(F[i][j - 1][k], F[i - 1][j][k]);
          T[i][j][k] = -1;
        }
      } else {
        for (int k = 0; k <= p - 1; k++) {
          F[i][j][k] = max(F[i][j - 1][k], F[i - 1][j][k]);
          T[i][j][k] = -1;
        }
        char kt = a[i - 1];
        for (int k = 0; k <= p; k++) cs[k] = 0;
        for (int k = 1; k <= p; k++)
          if (c[k - 1] == kt)
            cs[k - 1] = k;
          else {
            cs[k - 1] = cs[ne[k - 1]];
          }
        for (int k = 0; k <= p - 1; k++) {
          F[i][j][cs[k]] = max(F[i][j][cs[k]], F[i - 1][j - 1][k] + 1);
          if (F[i][j][cs[k]] == F[i - 1][j - 1][k] + 1) {
            T[i][j][cs[k]] = k;
          }
        }
      }
    }
  return 0;
}
int buoc3() {
  ans = 0;
  cs_luu = 0;
  for (int k = 0; k <= p - 1; k++)
    if (F[m][n][k] > ans) {
      ans = F[m][n][k];
      cs_luu = k;
    }
  return 0;
}
int buoc4() {
  int i = m;
  int j = n;
  int k = cs_luu;
  for (int xx = 1; xx <= ans; xx++) {
    while (0 != 1) {
      if (T[i][j][k] == -1) {
        if (F[i - 1][j][k] > F[i][j - 1][k])
          i--;
        else
          j--;
      } else {
        int k1 = T[i][j][k];
        kq[xx] = a[i - 1];
        i--;
        j--;
        k = k1;
        break;
      }
    }
  }
  for (int i = ans; i >= 2; i--) cout << kq[i];
  cout << kq[1] << endl;
  return 0;
}
int main() {
  getline(cin, a);
  getline(cin, b);
  getline(cin, c);
  m = a.length();
  n = b.length();
  p = c.length();
  for (int i = 0; i <= m; i++)
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= p; k++) F[i][j][k] = T[i][j][k] = -oo;
    }
  for (int i = 0; i <= m; i++) F[i][0][0] = 0;
  for (int j = 0; j <= n; j++) F[0][j][0] = 0;
  F[0][0][0] = 0;
  ans = 0;
  buoc1();
  buoc2();
  buoc3();
  if (ans == 0)
    cout << 0 << endl;
  else
    buoc4();
  return 0;
}