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;
void debug() { cout << endl; }
template <typename T, typename... Args>
void debug(T a, Args... args) {
  cout << a << ' ';
  debug(args...);
}
void prefix_function(string &s, vector<int> &pf) {
  int n = s.size();
  pf.assign(n, 0);
  for (int i = 1, j = 0; i < n; ++i) {
    while (j && s[i] != s[j]) j = pf[j - 1];
    if (s[i] == s[j]) j++;
    pf[i] = j;
  }
}
const int N = 100, oo = 1e8;
int dp[N][N][N];
vector<int> pf;
string s, t, p;
int f(int i, int j, int k) {
  if (k == p.size()) return -oo;
  if (i == s.size() || j == t.size()) return 0;
  int &r = dp[i][j][k];
  if (r > -1) return r;
  r = max(f(i + 1, j, k), f(i, j + 1, k));
  if (s[i] == t[j]) {
    while (k && s[i] != p[k]) k = pf[k - 1];
    if (s[i] == p[k]) k++;
    r = max(r, f(i + 1, j + 1, k) + 1);
  }
  return r;
}
string ans;
void bt(int i, int j, int k) {
  if (i == s.size() || j == t.size()) return;
  int r = f(i, j, k);
  if (r == f(i + 1, j, k)) {
    bt(i + 1, j, k);
  } else if (r == f(i, j + 1, k)) {
    bt(i, j + 1, k);
  } else if (s[i] == t[j]) {
    while (k && s[i] != p[k]) k = pf[k - 1];
    if (s[i] == p[k]) k++;
    if (r == f(i + 1, j + 1, k) + 1) {
      ans.push_back(s[i]);
      bt(i + 1, j + 1, k);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> s >> t >> p;
  prefix_function(p, pf);
  memset(dp, -1, sizeof dp);
  f(0, 0, 0);
  bt(0, 0, 0);
  if (ans.empty())
    cout << "0\n";
  else
    cout << ans << '\n';
}