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;
int const dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int const dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
int64_t const LIM = 150, INF = 1e9, MOD = 1e9 + 7;
double const PI = 3.141592653589793, EPS = 1e-7;
string a, b, c;
tuple<int, int, int> p[LIM][LIM][LIM];
bool use[LIM][LIM][LIM];
int d[LIM][LIM][LIM];
int relax(string s) {
  string c1 = c;
  reverse(c1.begin(), c1.end());
  string t = c1 + '$' + s;
  vector<int> p(t.length());
  for (int i = 1; i < (int)p.size(); i++) {
    int j = p[i - 1];
    while (j > 0 && t[i] != t[j]) j = p[j - 1];
    if (t[i] == t[j]) ++j;
    p[i] = j;
  }
  return p.back();
}
int f(int i, int j, int k, string s) {
  if (k == (int)c.length()) return -1;
  if (i == 0 || j == 0) return 0;
  if (d[i][j][k] != -1) return d[i][j][k];
  int x1 =
      (a[i] == b[j] ? (f(i - 1, j - 1, relax(s + a[i]), s + a[i]) + 1) : 0);
  int x2 = f(i - 1, j, k, s);
  int x3 = f(i, j - 1, k, s);
  d[i][j][k] = x1;
  use[i][j][k] = true;
  p[i][j][k] = make_tuple(i - 1, j - 1, relax(s + a[i]));
  if (x2 > d[i][j][k]) {
    d[i][j][k] = x2;
    use[i][j][k] = false;
    p[i][j][k] = make_tuple(i - 1, j, k);
  }
  if (x3 > d[i][j][k]) {
    use[i][j][k] = false;
    d[i][j][k] = x3;
    p[i][j][k] = make_tuple(i, j - 1, k);
  }
  if (d[i][j][k] == 0) {
    use[i][j][k] = false;
    p[i][j][k] = make_tuple(i, j, k);
  }
  return d[i][j][k];
}
string go(int i, int j, int k) {
  if (i == 0 || j == 0) return "";
  string res;
  if (p[i][j][k] != make_tuple(i, j, k))
    res = go(get<0>(p[i][j][k]), get<1>(p[i][j][k]), get<2>(p[i][j][k]));
  if (a[i] == b[j] && use[i][j][k]) res += a[i];
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> a >> b >> c;
  a = " " + a;
  b = " " + b;
  for (int i = 0; i < (int)a.length() + 1; i++)
    for (int j = 0; j < (int)b.length() + 1; j++)
      for (int k = 0; k < (int)c.length() + 1; k++) {
        d[i][j][k] = -1;
        p[i][j][k] = make_tuple(i, j, k);
      }
  if (f(a.length() - 1, b.length() - 1, 0, "")) {
    reverse(c.begin(), c.end());
    string ans = go(a.length() - 1, b.length() - 1, 0);
    cout << ans << '\n';
  } else {
    cout << 0 << '\n';
  }
  return 0;
}