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;
template <class L, class R>
ostream& operator<<(ostream& cout, pair<L, R> P) {
  return cout << '(' << P.first << ',' << P.second << ')';
}
template <class T>
ostream& operator<<(ostream& cout, vector<T> V) {
  cout << "[ ";
  for (auto v : V) cout << v << ' ';
  return cout << ']';
}
vector<long long> getPrefix(string str) {
  long long n = str.length();
  vector<long long> pi(n, 0);
  for (long long i = 1; i < n; ++i) {
    long long j = pi[i - 1];
    while (j > 0 && str[i] != str[j]) {
      j = pi[j - 1];
    }
    if (str[i] == str[j]) {
      ++j;
    }
    pi[i] = j;
  }
  return pi;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s1, s2, virus;
  cin >> s1 >> s2 >> virus;
  long long n = s1.length();
  long long m = s2.length();
  long long k = virus.length();
  string f[n + 5][m + 5][k + 5];
  for (long long i = 0; i < n + 5; ++i) {
    for (long long j = 0; j < m + 5; ++j) {
      for (long long t = 0; t < k + 5; ++t) {
        f[i][j][t] = "";
      }
    }
  }
  vector<long long> vec = getPrefix(virus);
  for (long long ix1 = 1; ix1 <= n; ++ix1) {
    for (long long ix2 = 1; ix2 <= m; ++ix2) {
      for (long long elen = 0; elen < virus.length(); ++elen) {
        string tmp1 = f[ix1][ix2 - 1][elen];
        string tmp2 = f[ix1 - 1][ix2][elen];
        f[ix1][ix2][elen] = (tmp1.length() > tmp2.length()) ? tmp1 : tmp2;
      }
      char c1 = s1[ix1 - 1], c2 = s2[ix2 - 1];
      if (c1 == c2) {
        for (long long pelen = 0; pelen < virus.length(); ++pelen) {
          long long tplen = pelen;
          while (tplen > 0 && (virus[tplen] != c1)) {
            tplen = vec[tplen - 1];
          }
          if (virus[tplen] == c1) {
            ++tplen;
          }
          string poss = f[ix1 - 1][ix2 - 1][pelen] + c1;
          if (tplen != virus.length() &&
              (poss.length() > f[ix1][ix2][tplen].length())) {
            f[ix1][ix2][tplen] = poss;
          }
        }
      }
    }
  }
  string ans = "";
  for (long long elen = 0; elen < virus.length(); ++elen) {
    if (ans.length() < f[n][m][elen].length()) {
      ans = f[n][m][elen];
    }
  }
  if (ans != "") {
    cout << ans;
  } else {
    cout << 0;
  }
}