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;
string a, b, v;
int n, l, x, memo[111][111][111];
vector<int> f;
int solve(int i, int j, int k) {
  if (k >= x) return -100000;
  if (i >= n || j >= l) return 0;
  int &ret = memo[i][j][k];
  if (ret != -1) return ret;
  ret = -100000;
  if (a[i] == b[j])
    ret = max(ret, 1 + solve(i + 1, j + 1,
                             a[i] == v[k]                   ? k + 1
                             : k > 0 && v[f[k - 1]] == a[i] ? f[k - 1] + 1
                                                            : 0));
  return ret = max(ret, max(solve(i, j + 1, k), solve(i + 1, j, k)));
}
vector<int> prefixFunction(string pat) {
  int m = pat.length();
  vector<int> longestPrefix(m);
  for (int i = 1, k = 0; i < m; i++) {
    while (k > 0 && pat[k] != pat[i]) {
      k = longestPrefix[k - 1];
    }
    if (pat[k] == pat[i])
      longestPrefix[i] = ++k;
    else
      longestPrefix[i] = k;
  }
  return longestPrefix;
}
void draw(int i = 0, int j = 0, int k = 0) {
  if (k >= x)
    ;
  if (i >= n || j >= l) return;
  int c1 = -100000;
  if (a[i] == b[j])
    c1 = 1 + solve(i + 1, j + 1,
                   a[i] == v[k]                   ? k + 1
                   : k > 0 && v[f[k - 1]] == a[i] ? f[k - 1] + 1
                                                  : 0);
  int c2 = solve(i, j + 1, k);
  int c3 = solve(i + 1, j, k);
  int maxc = max(c1, max(c2, c3));
  if (c1 == maxc) {
    cout << a[i];
    draw(i + 1, j + 1,
         a[i] == v[k]                   ? k + 1
         : k > 0 && v[f[k - 1]] == a[i] ? f[k - 1] + 1
                                        : 0);
    return;
  } else if (c2 == maxc) {
    draw(i, j + 1, k);
    return;
  } else if (c3 == maxc) {
    draw(i + 1, j, k);
    return;
  }
}
int main() {
  cin >> a >> b >> v;
  x = v.length();
  n = a.length();
  l = b.length();
  f = prefixFunction(v);
  memset(memo, -1, sizeof(memo));
  if (solve(0, 0, 0) > 0)
    draw();
  else
    cout << 0;
}