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 _T>
_T MAX(_T p1, _T p2) {
  return (p1 > p2) ? p1 : p2;
}
template <class _T>
_T MIN(_T p1, _T p2) {
  return (p1 < p2) ? p1 : p2;
}
template <class _Tv>
inline string join(const _Tv &v, string sep = " ") {
  ostringstream s;
  for (__typeof__((v).begin()) it = (v).begin(); it != (v).end(); ++it) {
    if (it != v.begin()) s << sep;
    s << *it;
  };
  return s.str();
}
void update(string &p1, const string &p2) {
  if (p1.size() < p2.size()) p1 = p2;
}
int strlap(const string &s1, const string &s2) {
  int l = MIN(s1.size(), s2.size());
  for (int i = l; i > 0; --i) {
    if (s1.substr(s1.size() - i, i) == s2.substr(0, i)) return i;
  }
  return 0;
}
string dp[101][101][101];
string lcs_ng(const string &s1, const string &s2, const string &ng) {
  int n1 = s1.size(), n2 = s2.size(), n3 = ng.size();
  for (int i = 1; i < n1 + 1; i++) {
    for (int j = (0); j < ((0) + (n2 + 1)); ++j) {
      if (i == 0 || j == 0) continue;
      for (int k = (0); k < ((0) + (n3)); ++k) {
        update(dp[k][i][j], dp[k][i][j - 1]);
        update(dp[k][i][j], dp[k][i - 1][j]);
        if (dp[k][i - 1][j - 1].size() < k) break;
        if (s1[i - 1] == s2[j - 1]) {
          string ts = dp[k][i - 1][j - 1] + s1[i - 1];
          int m = strlap(ts, ng);
          if (ng.size() != m) {
            update(dp[m][i][j], ts);
          }
        }
      }
    };
    for (int k = (0); k < ((0) + (n3 + 1)); ++k) {
      ;
      for (int j = (0); j < ((0) + (n2 + 1)); ++j)
        ;
      ;
    }
  }
  string ret;
  for (int k = (0); k < ((0) + (n3)); ++k) {
    ;
    if (ret.size() < dp[k][n1][n2].size()) ret = dp[k][n1][n2];
  }
  return ret;
}
int main() {
  do {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
  } while (0);
  string s1, s2, v;
  cin >> s1 >> s2 >> v;
  string ret = lcs_ng(s1, s2, v);
  if (ret.size() == 0) ret = "0";
  cout << ret << endl;
  ;
  return 0;
}