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 nxt[1000], f[120][120][120], go[300][300], lena, lenb, lenc, best;
char s1[1000], s2[1000], p[1000];
pair<pair<int, int>, pair<int, char> > path[120][120][120];
string ans;
inline int max(int a, int b) { return a > b ? a : b; }
void kmp() {
  int j = 0;
  for (int i = 2; i <= lenc; ++i) {
    while (j > 0 && p[j + 1] != p[i]) j = nxt[j];
    if (p[j + 1] == p[i]) j++;
    nxt[i] = j;
  }
}
int main() {
  scanf("%s%s%s", s1 + 1, s2 + 1, p + 1);
  lena = strlen(s1 + 1);
  lenb = strlen(s2 + 1);
  lenc = strlen(p + 1);
  kmp();
  for (int i = 0; i <= lenc; ++i)
    for (int j = 0; j <= 150; ++j) {
      int k = i;
      while (k > 0 && p[k + 1] != j) k = nxt[k];
      if (p[k + 1] == j) go[i][j] = k + 1;
    }
  for (int i = 0; i <= lena; ++i)
    for (int j = 0; j <= lenb; ++j)
      for (int k = 0; k <= lenc - 1; ++k) {
        if (f[i][j][k] > f[i + 1][j][k]) {
          f[i + 1][j][k] = f[i][j][k];
          path[i + 1][j][k] = path[i][j][k];
        }
        if (f[i][j][k] > f[i][j + 1][k]) {
          f[i][j + 1][k] = f[i][j][k];
          path[i][j + 1][k] = path[i][j][k];
        }
        if (s1[i + 1] == s2[j + 1])
          if (f[i][j][k] + 1 > f[i + 1][j + 1][go[k][s1[i + 1]]]) {
            f[i + 1][j + 1][go[k][s1[i + 1]]] = f[i][j][k] + 1;
            path[i + 1][j + 1][go[k][s1[i + 1]]] =
                make_pair(make_pair(i, j), make_pair(k, s1[i + 1]));
          }
      }
  for (int k = 0; k <= lenc - 1; ++k)
    if (f[lena][lenb][k] > f[lena][lenb][best]) best = k;
  if (f[lena][lenb][best] == 0) {
    puts("0");
    return 0;
  }
  int ci = lena, cj = lenb, ck = best;
  while (f[ci][cj][ck]) {
    ans = path[ci][cj][ck].second.second + ans;
    int cci = path[ci][cj][ck].first.first;
    int ccj = path[ci][cj][ck].first.second;
    int cck = path[ci][cj][ck].second.first;
    ci = cci, cj = ccj, ck = cck;
  }
  cout << ans << endl;
  return 0;
}