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;
const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long lcm(long long a, long long b) { return (a * (b / gcd(a, b))); }
string s1, s2, v;
int n, m, x;
int memo[111][111][111], f[111];
void kmpPreprocess() {
  int i = 0, j = -1;
  f[0] = -1;
  while (i < v.length()) {
    while (j >= 0 && v[i] != v[j]) j = f[j];
    i++;
    j++;
    f[i] = j;
  }
}
int solve(int i, int j, int k) {
  if (k == x) return -10000;
  if (i == n || j == m) return 0;
  int &ret = memo[i][j][k];
  if (ret != -1) return ret;
  ret = -10000;
  if (s1[i] == s2[j])
    ret = max(
        ret,
        1 + solve(i + 1, j + 1,
                  v[k] == s1[i] ? k + 1 : (v[f[k]] == s1[i] ? f[k] + 1 : 0)));
  ret = max(ret, solve(i + 1, j, k));
  ret = max(ret, solve(i, j + 1, k));
  return ret;
}
void print(int i, int j, int k) {
  if (k == x) return;
  if (i == n || j == m) return;
  int ret = memo[i][j][k];
  if (s1[i] == s2[j] &&
      1 + solve(i + 1, j + 1,
                v[k] == s1[i] ? k + 1 : (v[f[k]] == s1[i] ? f[k] + 1 : 0)) ==
          ret)
    cout << s1[i],
        print(i + 1, j + 1,
              v[k] == s1[i] ? k + 1 : (v[f[k]] == s1[i] ? f[k] + 1 : 0));
  else if (ret == solve(i + 1, j, k))
    print(i + 1, j, k);
  else
    print(i, j + 1, k);
}
void solution() {
  cin >> s1 >> s2 >> v;
  n = s1.length();
  m = s2.length();
  x = v.length();
  kmpPreprocess();
  f[0] = 0;
  memset(memo, -1, sizeof(memo));
  ;
  if (solve(0, 0, 0))
    print(0, 0, 0);
  else
    cout << 0;
}
int main() {
  double beg = clock();
  ios::sync_with_stdio(false);
  solution();
  return 0;
}