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;
using vi = vector<int>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
using vll = vector<LL>;
using LD = long double;
template <typename T>
void check(T& a, const T& b) {
  if (a >= b) {
    a %= b;
  }
}
template <typename T>
T gcd(T u, T v) {
  if (u == v) return u;
  if (u == 0) return v;
  if (v == 0) return u;
  if (~u & 1) {
    if (v & 1)
      return gcd(u >> 1, v);
    else
      return gcd(u >> 1, v >> 1) << 1;
  }
  if (~v & 1) return gcd(u, v >> 1);
  if (u > v) return gcd((u - v) >> 1, v);
  return gcd((v - u) >> 1, u);
}
LL mulmod(LL a, LL b, const LL& m) {
  LL q = (LL)(((LD)a * (LD)b) / (LD)m);
  LL r = a * b - q * m;
  if (r > m) r %= m;
  if (r < 0) r += m;
  return r;
}
template <typename T, typename S>
T expo(T e, S n) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = x * p;
    p = p * p;
    n >>= 1;
  }
  return x;
}
template <typename T>
T powerL(T e, T n, const T& m) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = mulmod(x, p, m);
    p = mulmod(p, p, m);
    n >>= 1;
  }
  return x;
}
const int N = (int)110;
int dp[N][N][N], n, m, l;
vi take[N][N][N];
string s1, s2, v;
vi PI;
vector<int> kmp(string& KMP) {
  int KMPN = (int)KMP.size();
  int q = -1;
  vector<int> pi(KMPN);
  pi[0] = -1;
  for (int i = 1; i < KMPN; i++) {
    while (q >= 0 && KMP[i] != KMP[q + 1]) q = pi[q];
    if (KMP[i] == KMP[q + 1]) q++;
    pi[i] = q;
  }
  return pi;
}
int solve(int i, int j, int k) {
  if (k >= l - 1) return -(int)1e9;
  if (i >= n || j >= m) return 0;
  int& ans = dp[i][j][(k == -1 ? 102 : k)];
  auto& _ans = take[i][j][(k == -1 ? 102 : k)];
  if (ans != -1) return ans;
  if (s1[i] == s2[j]) {
    int tk = k;
    while (k >= 0 && s1[i] != v[k + 1]) k = PI[k];
    if (s1[i] == v[k + 1]) k++;
    ans = 1 + solve(i + 1, j + 1, k);
    _ans = {i + 1, j + 1, k};
    k = tk;
    int x = solve(i + 1, j, k), y = solve(i, j + 1, k);
    if (x > ans) {
      ans = x;
      _ans = {i + 1, j, k};
    }
    if (y > ans) {
      ans = y;
      _ans = {i, j + 1, k};
    }
    return ans;
  }
  int x = solve(i + 1, j, k), y = solve(i, j + 1, k);
  ans = x;
  _ans = {i + 1, j, k};
  if (y > ans) {
    ans = y;
    _ans = {i, j + 1, k};
  }
  return ans;
}
void gen(int i, int j, int k, string& Gen) {
  if (i >= n || j >= m) return;
  vi& ans = take[i][j][(k == -1 ? 102 : k)];
  if (ans[0] == i + 1 && ans[1] == j + 1) Gen += s1[i];
  gen(ans[0], ans[1], ans[2], Gen);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cerr.tie(NULL);
  ;
  memset(dp, -1, sizeof dp);
  cin >> s1 >> s2 >> v;
  PI = kmp(v);
  n = (int)s1.size(), m = (int)s2.size(), l = (int)v.size();
  int ans = solve(0, 0, -1);
  if (ans <= 0) {
    cout << 0 << '\n';
    return 0;
  }
  string Gen = "";
  gen(0, 0, -1, Gen);
  cout << Gen << '\n';
  return 0;
}