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>
void mini(T& a, T b) {
  a = min(a, b);
}
template <class T>
void maxi(T& a, T b) {
  a = max(a, b);
}
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  return out << a.first << " " << a.second;
}
template <class T>
ostream& operator<<(ostream& out, vector<T> a) {
  for (auto& i : a) out << i << " ";
  return out;
}
template <class T>
ostream& operator<<(ostream& out, set<T> a) {
  for (auto& i : a) out << i << " ";
  return out;
}
template <class T1, class T2>
ostream& operator<<(ostream& out, map<T1, T2> a) {
  for (auto& i : a) out << i << " ";
  return out;
}
template <class T>
void out(T a) {
  cout << a << endl;
}
void out() { cout << "OK" << endl; }
const int N = 105;
int to[N][26];
int link[N];
int sz = 1;
queue<int> q;
void add_str(string s) {
  int v = 0;
  for (char c : s) {
    c -= 'A';
    if (!to[v][c]) to[v][c] = sz++;
    v = to[v][c];
  }
}
void push_links() {
  q.push(0);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    int u = link[v];
    for (int c = 0; c < 26; c++) {
      if (to[v][c]) {
        link[to[v][c]] = v ? to[u][c] : 0;
        q.push(to[v][c]);
      } else
        to[v][c] = to[u][c];
    }
  }
}
string s;
string t;
string v;
int dp[N][N][N];
string op[N][N][N];
string ans;
void Solve() {
  cin >> s >> t >> v;
  add_str(v);
  push_links();
  int n = s.size();
  int m = t.size();
  int u = v.size();
  s = "$" + s;
  t = "$" + t;
  v = "$" + v;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      for (int k = 1; k <= u; k++) {
        int cdp = dp[i][j][k];
        string cop = op[i][j][k];
        if (i < n && j < m && s[i + 1] == t[j + 1]) {
          char c = s[i + 1];
          int nk = to[k - 1][c - 'A'] + 1;
          if (nk <= u && dp[i + 1][j + 1][nk] < cdp + 1) {
            dp[i + 1][j + 1][nk] = cdp + 1;
            op[i + 1][j + 1][nk] = cop + c;
          }
        }
        if (i < n && dp[i + 1][j][k] < cdp) {
          dp[i + 1][j][k] = cdp;
          op[i + 1][j][k] = cop;
        }
        if (j < m && dp[i][j + 1][k] < cdp) {
          dp[i][j + 1][k] = cdp;
          op[i][j + 1][k] = cop;
        }
      }
    }
  }
  string ans;
  for (int i = 1; i <= u; i++) {
    if (dp[n][m][i] > ans.size()) {
      ans = op[n][m][i];
    }
  }
  if (ans.empty())
    out(0);
  else
    out(ans);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  Solve();
  return 0;
}