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;
using LL = long long;
void Print() { cout << endl; }
template <typename T1, typename... T>
void Print(const T1 &t1, const T &...t) {
  cout << t1 << " ";
  Print(t...);
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <class Iterator>
ostream &output_cantainer(ostream &os, Iterator first, Iterator last,
                          bool space = true) {
  if (space) {
    for (Iterator it = first; it != last; it++) {
      os << (*it) << ' ';
    }
    os << endl;
  } else
    for (Iterator it = first; it != last; it++) {
      os << (*it) << endl;
    }
  return os;
}
const int N = 105;
char s1[N], s2[N], v[N];
int dp[N][N][N], ptr[N][N][N];
bool pick[N][N][N];
int m, n, l, p[N];
void process() {
  int last = 0;
  for (int i = 2; i <= l; i++) {
    while (last > 0 && v[i] != v[last + 1]) last = p[last];
    if (v[i] == v[last + 1]) p[i] = ++last;
  }
}
string output(int i, int j, int k) {
  if (i == 0 || j == 0) return "";
  if (!pick[i][j][k]) {
    if (dp[i - 1][j][k] >= dp[i][j - 1][k]) return output(i - 1, j, k);
    return output(i, j - 1, k);
  }
  return output(i - 1, j - 1, ptr[i][j][k]) + string(1, s1[i]);
}
int main() {
  cin >> (s1 + 1) >> (s2 + 1) >> (v + 1);
  m = strlen(s1 + 1);
  n = strlen(s2 + 1);
  l = strlen(v + 1);
  process();
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (s1[i] == s2[j]) {
        for (int k = 0; k < l; k++) {
          int t = k;
          while (t > 0 && v[t + 1] != s1[i]) t = p[t];
          if (v[t + 1] == s1[i]) {
            if (dp[i - 1][j - 1][k] + 1 > dp[i][j][t + 1])
              dp[i][j][t + 1] = dp[i - 1][j - 1][k] + 1, ptr[i][j][t + 1] = k,
                           pick[i][j][t + 1] = true;
          } else if (dp[i - 1][j - 1][k] + 1 > dp[i][j][0])
            dp[i][j][0] = dp[i - 1][j - 1][k] + 1, ptr[i][j][0] = k,
            pick[i][j][0] = true;
        }
      }
      for (int k = 0; k < l; k++)
        if (dp[i][j - 1][k] > dp[i][j][k] || dp[i - 1][j][k] > dp[i][j][k])
          dp[i][j][k] = max(dp[i - 1][j][k], dp[i][j - 1][k]),
          pick[i][j][k] = false;
    }
  }
  int wh = 0;
  for (int i = 1; i < l; i++)
    if (dp[m][n][i] > dp[m][n][wh]) wh = i;
  if (dp[m][n][wh] == 0)
    cout << 0 << endl;
  else
    cout << output(m, n, wh) << endl;
}