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 long long MAXN = 1e6 + 5;
const long long INF = 1e6;
long long n, m, l, ans, dp[105][105][105], nex[105];
char str1[105], str2[105], str3[105];
stack<char> s;
struct sta {
  long long i, j, k;
} re[105][105][105], pre[105][105][105];
void calc_next() {
  nex[1] = 0;
  long long k = 0;
  for (long long i = 2; i <= l; i++) {
    while (k > 0 && str3[k + 1] != str3[i]) {
      k = nex[k];
    }
    if (str3[k + 1] == str3[i]) {
      k++;
    }
    nex[i] = k;
  }
}
int main() {
  while (~scanf("%s", str1 + 1)) {
    scanf("%s", str2 + 1);
    scanf("%s", str3 + 1);
    n = strlen(str1 + 1);
    m = strlen(str2 + 1);
    l = strlen(str3 + 1);
    calc_next();
    for (long long i = 0; i <= n; i++) {
      for (long long j = 0; j <= m; j++) {
        for (long long k = 1; k <= l; k++) {
          dp[i][j][k] = -INF;
          re[i][j][k] = sta{0, 0, 0};
          pre[i][j][k] = sta{0, 0, 0};
        }
      }
    }
    for (long long i = 1; i <= n; i++) {
      for (long long j = 1; j <= m; j++) {
        for (long long k = 1; k < l; k++) {
          if (str1[i] == str2[j]) {
            if (str1[i] == str3[k]) {
              dp[i][j][k] = dp[i - 1][j - 1][k - 1] + 1;
              re[i][j][k] = sta{i, j, k};
              pre[i][j][k] = re[i - 1][j - 1][k - 1];
              ans = max(ans, dp[i][j][k]);
            }
          }
        }
        if (str1[i] == str2[j]) {
          for (long long k = 0; k < l; k++) {
            if (str1[i] != str3[k + 1]) {
              long long bac = nex[k];
              if (str1[i] == str3[bac + 1]) {
                bac++;
              } else {
                bac = 0;
              }
              if (dp[i - 1][j - 1][k] + 1 > dp[i][j][bac]) {
                dp[i][j][bac] = dp[i - 1][j - 1][k] + 1;
                re[i][j][bac] = sta{i, j, bac};
                pre[i][j][bac] = re[i - 1][j - 1][k];
                ans = max(ans, dp[i][j][bac]);
              }
            }
          }
        }
        for (long long k = 0; k < l; k++) {
          if (dp[i - 1][j][k] > dp[i][j - 1][k]) {
            if (dp[i - 1][j][k] > dp[i][j][k]) {
              dp[i][j][k] = dp[i - 1][j][k];
              re[i][j][k] = re[i - 1][j][k];
            }
          } else {
            if (dp[i][j - 1][k] > dp[i][j][k]) {
              dp[i][j][k] = dp[i][j - 1][k];
              re[i][j][k] = re[i][j - 1][k];
            }
          }
        }
      }
    }
    if (!ans) {
      printf("0\n");
      continue;
    }
    long long flag = 0;
    for (long long i = 1; i <= n && !flag; i++) {
      for (long long j = 1; j <= m && !flag; j++) {
        for (long long k = 0; k < l && !flag; k++) {
          if (dp[i][j][k] == ans) {
            long long nexi, nexj, nexk;
            while (pre[i][j][k].i != 0) {
              s.push(str1[i]);
              nexi = pre[i][j][k].i;
              nexj = pre[i][j][k].j;
              nexk = pre[i][j][k].k;
              i = nexi;
              j = nexj;
              k = nexk;
            }
            s.push(str1[i]);
            flag = 1;
            break;
          }
        }
      }
    }
    while (!s.empty()) {
      printf("%c", s.top());
      s.pop();
    }
  }
}