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 <typename _Tp>
bool maximize(_Tp &__a, _Tp __b) {
  if (__a < __b) {
    __a = __b;
    return true;
  }
  return false;
}
template <typename _Tp>
bool minimize(_Tp &__a, _Tp __b) {
  if (__a > __b) {
    __a = __b;
    return true;
  }
  return false;
}
const int siz = 1e2 + 2;
const int SIZ = 1e6 + 2;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const long long MAXX = 1e18;
const string file = "3";
int n, m, l;
string a, b, c;
int nxt[siz][26];
int f[siz][siz][siz];
bool g[siz][siz][siz];
int dp(int pos_a, int pos_b, int pos_c) {
  if (pos_a == n + 1 || pos_b == m + 1) {
    return 0;
  }
  int &res = f[pos_a][pos_b][pos_c];
  bool &cal = g[pos_a][pos_b][pos_c];
  if (cal) {
    return res;
  }
  res = max(dp(pos_a + 1, pos_b, pos_c), dp(pos_a, pos_b + 1, pos_c));
  if (a[pos_a] == b[pos_b]) {
    if (nxt[pos_c][a[pos_a] - 'A'] != l + 1) {
      maximize(res, dp(pos_a + 1, pos_b + 1, nxt[pos_c][a[pos_a] - 'A']) + 1);
    }
  }
  cal = true;
  return res;
}
void trace(int pos_a, int pos_b, int pos_c) {
  if (pos_a == n + 1 || pos_b == m + 1) {
    return;
  }
  int res = dp(pos_a, pos_b, pos_c);
  if (res == dp(pos_a + 1, pos_b, pos_c)) {
    trace(pos_a + 1, pos_b, pos_c);
    return;
  } else if (res == dp(pos_a, pos_b + 1, pos_c)) {
    trace(pos_a, pos_b + 1, pos_c);
    return;
  }
  if (a[pos_a] == b[pos_b]) {
    if (nxt[pos_c][a[pos_a] - 'A'] != l + 1) {
      if (res == dp(pos_a + 1, pos_b + 1, nxt[pos_c][a[pos_a] - 'A']) + 1) {
        cout << a[pos_a];
        trace(pos_a + 1, pos_b + 1, nxt[pos_c][a[pos_a] - 'A']);
        return;
      }
    }
  }
  assert(0);
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> a >> b >> c;
  n = (int)(a).size();
  a = ' ' + a;
  m = (int)(b).size();
  b = ' ' + b;
  l = (int)(c).size();
  c = ' ' + c;
  for (int i = (int)(1); i <= (int)(l); i++) {
    char org = c[i];
    for (int chr = (int)('A'); chr <= (int)('Z'); chr++) {
      c[i] = chr;
      int pos = 1;
      for (int len = (int)(1); len <= (int)(i - 1); len++) {
        if (c.substr(1, len) == c.substr(i - len + 1, len)) {
          pos = len + 1;
        }
      }
      nxt[i][chr - 'A'] = pos;
    }
    c[i] = org;
    nxt[i][c[i] - 'A'] = i + 1;
  }
  if (dp(1, 1, 1) == 0) {
    return cout << 0 << "\n", 0;
  }
  trace(1, 1, 1);
  cout << "\n";
  return 0;
}