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 long long inf = -1e6;
long long lcs[102][102][102];
string s1, s2, pat;
pair<pair<long long, long long>, long long> p[102][102][102];
bool bb[102][102][102];
struct KMP {
  string p;
  int n;
  vector<int> lcp;
  void init(string s) {
    p = s;
    n = p.length();
  }
  void compute_lcp() {
    lcp.resize(n, 0);
    int j = 0;
    for (int i = 1; i < n; i++) {
      while (j > 0 && p[j] != p[i]) j = lcp[j - 1];
      if (p[j] == p[i]) j++;
      lcp[i] = j;
    }
  }
  void kmp(string t) {
    int m = t.length();
    int j = 0;
    for (int i = 0; i < m; i++) {
      while (j > 0 && p[j] != t[i]) j = lcp[j - 1];
      if (p[j] == t[i]) j++;
      if (j == n) {
        printf("%d ", i);
        j = lcp[j - 1];
      }
    }
  }
};
void f(long long a, long long b, long long c) {
  if (c == -1) return;
  f(p[a][b][c].first.first, p[a][b][c].first.second, p[a][b][c].second);
  if (bb[a][b][c]) cout << s1[a - 1];
}
int main() {
  cin >> s1 >> s2 >> pat;
  long long n1 = s1.length();
  long long n2 = s2.length();
  long long n3 = pat.length();
  KMP ssh;
  ssh.init(pat);
  ssh.compute_lcp();
  for (long long i = 0; i <= n1; i++)
    for (long long j = 0; j <= n2; j++)
      for (long long k = 0; k <= n3; k++)
        lcs[i][j][k] = inf, p[i][j][k] = {{-1, -1}, -1};
  lcs[0][0][0] = 0;
  for (long long i = 1; i <= n1; i++) lcs[i][0][0] = 0;
  for (long long i = 1; i <= n2; i++) lcs[0][i][0] = 0;
  long long ans = 0;
  for (long long i = 1; i <= n1; i++) {
    for (long long j = 1; j <= n2; j++) {
      for (long long k = 0; k <= n3; k++) {
        if (k < n3) {
          if (lcs[i - 1][j][k] > lcs[i][j][k]) {
            lcs[i][j][k] = lcs[i - 1][j][k];
            p[i][j][k] = {{i - 1, j}, k};
            bb[i][j][k] = 0;
          }
          if (lcs[i][j - 1][k] > lcs[i][j][k]) {
            lcs[i][j][k] = lcs[i][j - 1][k];
            p[i][j][k] = {{i, j - 1}, k};
            bb[i][j][k] = 0;
          }
        }
        if (s1[i - 1] == s2[j - 1]) {
          if (k == 0 and s1[i - 1] != pat[0]) {
            lcs[i][j][0] = 1;
            bb[i][j][0] = 1;
            p[i][j][0] = {{-1, -1}, -1};
          } else {
            long long jj = k - 1;
            long long ii = i - 1;
            while (jj > 0 && ssh.p[jj] != s1[ii]) jj = ssh.lcp[jj - 1];
            if (ssh.p[jj] == s1[ii]) jj++;
            if (jj < n3) {
              if (lcs[i][j][jj] < lcs[i - 1][j - 1][k - 1] + 1) {
                lcs[i][j][jj] = lcs[i - 1][j - 1][k - 1] + 1;
                p[i][j][jj] = {{i - 1, j - 1}, k - 1};
                bb[i][j][jj] = 1;
              }
            }
          }
        }
      }
    }
  }
  for (long long i = 0; i <= n1; i++) {
    for (long long j = 0; j <= n2; j++) {
      for (long long k = 0; k <= n3 - 1; k++) {
        ans = max(ans, lcs[i][j][k]);
      }
    }
  }
  if (ans <= 0)
    cout << "0\n";
  else {
    for (long long i = 0; i <= n1; i++) {
      for (long long j = 0; j <= n2; j++) {
        for (long long k = 0; k <= n3 - 1; k++) {
          if (lcs[i][j][k] == ans) {
            f(i, j, k);
            cout << "\n";
            goto hell;
          }
        }
      }
    }
  }
hell:
  cout << "";
}