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 <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
const double pi = 2 * asin(1.0);
int n;
int n1, n2;
int m;
vector<int> pref(char* s) {
  vector<int> p = vector<int>(n, 0);
  for (int i = 1; i < n; i++) {
    int x = p[i - 1];
    while (x > 0 && s[i] != s[x]) {
      x = p[x - 1];
    }
    if (s[i] == s[x]) x++;
    p[i] = x;
  }
  return p;
}
char s1[102], s2[102], v[102];
int aut[100][26];
string ff[102][102][102];
bool was[102][102][102];
string maxx(string s1, string s2) {
  if (s1.length() > s2.length())
    return s1;
  else
    return s2;
}
string f(int a, int b, int c) {
  if (was[a][b][c]) return ff[a][b][c];
  if (a == n1 || b == n2) return "";
  was[a][b][c] = true;
  ff[a][b][c] = maxx(f(a + 1, b, c), f(a, b + 1, c));
  if (s1[a] == s2[b] && aut[c][s1[a] - 'A'] != n)
    ff[a][b][c] =
        maxx(s1[a] + f(a + 1, b + 1, aut[c][s1[a] - 'A']), ff[a][b][c]);
  return ff[a][b][c];
}
int main() {
  gets(s1);
  n1 = strlen(s1);
  gets(s2);
  n2 = strlen(s2);
  gets(v);
  n = strlen(v);
  vector<int> p = pref(v);
  memset(was, false, sizeof(was));
  for (int i = 0; i < n; i++) {
    for (char ch = 'A'; ch <= 'Z'; ch++) {
      if (i > 0 && v[i] != ch) {
        aut[i][ch - 'A'] = aut[p[i - 1]][ch - 'A'];
      } else {
        aut[i][ch - 'A'] = i + (int)(v[i] == ch);
      }
    }
  }
  f(0, 0, 0);
  if (ff[0][0][0].length() == 0)
    printf("0\n");
  else
    cout << ff[0][0][0];
  return 0;
}