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;
inline void wait(double seconds) {
  double endtime = clock() + (seconds * CLOCKS_PER_SEC);
  while (clock() < endtime) {
    ;
  }
}
template <class T>
inline T fastIn() {
  register char c = 0;
  register T a = 0;
  bool neg = false;
  while (c < 33) c = getchar();
  while (c > 33) {
    if (c == '-') {
      neg = true;
    } else {
      a = (a * 10) + (c - '0');
    }
    c = getchar();
  }
  return neg ? -a : a;
}
string s1, s2;
string s3;
int l1, l2, l3;
inline void read() {
  cin >> s1 >> s2;
  cin >> s3;
  l1 = (int)(s1).length(), l2 = (int)(s2).length(), l3 = (int)(s3).length();
}
int const mxn = 200;
int pi[mxn];
inline void prefix_function(string const s) {
  int n = (int)(s).length();
  memset(pi, 0, sizeof(pi));
  for (int i = 1; i < n; ++i) {
    int j = pi[i - 1];
    while (j > 0 && s[i] != s[j]) {
      j = pi[j - 1];
    }
    if (s[i] == s[j]) {
      ++j;
    }
    pi[i] = j;
  }
  return;
}
int aut[mxn][30];
inline void kmp_autometa(string const s) {
  memset(aut, 0, sizeof(aut));
  prefix_function(s + "[");
  int n = (int)(s).length();
  for (int i = 0; i < n; ++i) {
    for (char c = 'A'; c <= '['; ++c) {
      if (i > 0 && c != s[i]) {
        aut[i][c - 'A'] = aut[pi[i - 1]][c - 'A'];
      } else {
        aut[i][c - 'A'] = i + (c == s[i]);
      }
    }
  }
}
int dp[mxn][mxn][mxn];
bool seen[mxn][mxn][mxn];
int const inf = 1023456789;
int go(int a, int b, int c) {
  if (c >= l3) return -inf;
  if (a >= l1 || b >= l2) {
    return 0;
  }
  int bst = 0;
  if (seen[a][b][c]) return dp[a][b][c];
  seen[a][b][c] = true;
  int v1 = go(a + 1, b, c);
  bst = max(bst, v1);
  int v2 = go(a, b + 1, c);
  bst = max(bst, v2);
  if (s1[a] == s2[b]) {
    int const nxt_c = aut[c][s1[a] - 'A'];
    int const v3 = go(a + 1, b + 1, nxt_c) + 1;
    bst = max(bst, v3);
  }
  return dp[a][b][c] = bst;
}
void bk(int a, int b, int c, int retval) {
  if (c >= l3) return;
  if (a >= l1 || b >= l2) return;
  int v1 = go(a + 1, b, c);
  if (v1 == retval) {
    bk(a + 1, b, c, retval);
    return;
  }
  int v2 = go(a, b + 1, c);
  if (v2 == retval) {
    bk(a, b + 1, c, retval);
    return;
  }
  if (s1[a] == s2[b]) {
    int const nxt_c = aut[c][s1[a] - 'A'];
    int const v3 = go(a + 1, b + 1, nxt_c) + 1;
    if (v3 == retval) {
      cout << s1[a];
      bk(a + 1, b + 1, nxt_c, retval - 1);
      return;
    }
  }
  return;
}
inline void proc() {
  memset(seen, false, sizeof(seen));
  kmp_autometa(s3);
  int retval = go(0, 0, 0);
  retval = max(retval, 0);
  if (!retval) {
    cout << 0 << "\n";
    return;
  }
  bk(0, 0, 0, retval);
  puts("");
}
int main() {
  int kase = 1;
  for (int i = 0, j1 = kase; i < j1; ++i) {
    read();
    proc();
  }
  return 0;
}