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 int N = 105;
char a[N], b[N], c[N];
int la, lb, lc, nxt[N], f[N][N][N];
string fr[N][N][N];
inline void getp(char f[], int nf, int p[]) {
  p[0] = -1;
  p[1] = 0;
  for (int i = 2; i <= nf; i++) {
    p[i] = p[i - 1] + 1;
    while ((p[i] != 0) && (f[p[i]] != f[i])) p[i] = p[p[i] - 1] + 1;
  }
}
inline void upd(int &a, int b, string &fa, string fb) {
  if (b > a) {
    a = b;
    fa = fb;
  }
}
int main() {
  scanf("%s%s%s", a + 1, b + 1, c + 1);
  la = strlen(a + 1);
  lb = strlen(b + 1);
  lc = strlen(c + 1);
  getp(c, lc, nxt);
  memset(f, 128, sizeof(f));
  int tp;
  f[0][0][0] = 0;
  for (int i = 0; i <= la; ++i)
    for (int j = 0; j <= lb; ++j)
      for (int k = 0; k < lc; ++k) {
        if (i < la)
          upd(f[i + 1][j][k], f[i][j][k], fr[i + 1][j][k], fr[i][j][k]);
        if (j < lb)
          upd(f[i][j + 1][k], f[i][j][k], fr[i][j + 1][k], fr[i][j][k]);
        if (i < la && j < lb && a[i + 1] == b[j + 1]) {
          for (tp = k; tp && c[tp + 1] != a[i + 1]; tp = nxt[tp])
            ;
          if (tp == 0)
            tp = c[1] == a[i + 1];
          else
            ++tp;
          upd(f[i + 1][j + 1][tp], f[i][j][k] + 1, fr[i + 1][j + 1][tp],
              fr[i][j][k] + a[i + 1]);
        }
      }
  int ans = 0;
  string st = "";
  for (int i = 0; i < lc; ++i) upd(ans, f[la][lb][i], st, fr[la][lb][i]);
  puts(ans ? st.c_str() : "0");
  return 0;
}