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 n, m, l;
char a[105], b[105], c[105];
int ne[105];
inline void init() {
  gets(a + 1);
  gets(b + 1);
  gets(c + 1);
  n = strlen(a + 1);
  m = strlen(b + 1);
  l = strlen(c + 1);
  ne[1] = 0;
  for (int i = 2; i <= l; ++i) {
    int j = ne[i - 1];
    for (; j && c[i] != c[j + 1]; j = ne[j])
      ;
    ne[i] = c[i] == c[j + 1] ? j + 1 : 0;
  }
}
struct dpval {
  int len, c, pi, pj, pk;
  inline friend bool operator>(const dpval &a, const dpval &b) {
    return a.len > b.len;
  }
} dp[105][105][105];
inline void upd(dpval &x, const dpval &v) {
  if (v > x) x = v;
}
char ans[105];
inline void solve() {
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= m; ++j)
      for (int k = 0; k < l; ++k) dp[i][j][k].len = -1;
  dp[0][0][0].len = 0;
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= m; ++j)
      for (int k = 0; k < l; ++k) {
        dpval &f = dp[i][j][k];
        if (f.len == -1) continue;
        if (i < n) upd(dp[i + 1][j][k], f);
        if (j < m) upd(dp[i][j + 1][k], f);
        if (i == n || j == m || a[i + 1] != b[j + 1]) continue;
        const dpval g = (dpval){f.len + 1, a[i + 1], i, j, k};
        if (a[i + 1] == c[k + 1])
          upd(dp[i + 1][j + 1][k + 1], g);
        else {
          int t = k;
          for (; t && c[t + 1] != g.c; t = ne[t])
            ;
          t = c[t + 1] == g.c ? t + 1 : 0;
          upd(dp[i + 1][j + 1][t], g);
        }
      }
  dpval f = (dpval){0, 0, 0, 0, 0};
  for (int i = 0; i < l; ++i) upd(f, dp[n][m][i]);
  if (!f.len)
    puts("0");
  else {
    for (; f.len; f = dp[f.pi][f.pj][f.pk]) ans[f.len] = f.c;
    puts(ans + 1);
  }
}
int main() {
  init();
  solve();
  return 0;
}