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;
char A[100 + 3], B[100 + 3], C[100 + 3], Ans[100 + 3];
int f[100 + 3][100 + 3][100 + 3], prei[100 + 3][100 + 3][100 + 3],
    prej[100 + 3][100 + 3][100 + 3], prek[100 + 3][100 + 3][100 + 3];
int Go[100 + 3][26], fail[100 + 3], la, lb, lc, len, ansi, ansj, ansk;
int main() {
  scanf("%s%s%s", A + 1, B + 1, C + 1);
  la = strlen(A + 1);
  lb = strlen(B + 1);
  lc = strlen(C + 1);
  Go[0][C[1] - 'A'] = 1;
  Go[1][C[1] - 'A'] = 1;
  Go[1][C[2] - 'A'] = 2;
  for (int i = 2; i <= lc; i++) {
    int w = fail[i - 1];
    for (; w && C[w + 1] != C[i]; w = fail[w])
      ;
    if (C[i] == C[w + 1]) w++;
    fail[i] = w;
    for (int j = 0; j < 26; j++) {
      int w = i;
      for (; w && C[w + 1] - 'A' != j; w = fail[w])
        ;
      if (C[w + 1] - 'A' == j) w++;
      Go[i][j] = w;
    }
  }
  memset(f, 130, sizeof(f));
  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 (f[i][j][k] < 0) continue;
        if (f[i + 1][j][k] < f[i][j][k]) {
          f[i + 1][j][k] = f[i][j][k];
          prei[i + 1][j][k] = i;
          prej[i + 1][j][k] = j;
          prek[i + 1][j][k] = k;
        }
        if (f[i][j + 1][k] < f[i][j][k]) {
          f[i][j + 1][k] = f[i][j][k];
          prei[i][j + 1][k] = i;
          prej[i][j + 1][k] = j;
          prek[i][j + 1][k] = k;
        }
        if (A[i + 1] == B[j + 1]) {
          int tk = Go[k][A[i + 1] - 'A'];
          if (f[i + 1][j + 1][tk] < f[i][j][k] + 1) {
            f[i + 1][j + 1][tk] = f[i][j][k] + 1;
            prei[i + 1][j + 1][tk] = i;
            prej[i + 1][j + 1][tk] = j;
            prek[i + 1][j + 1][tk] = k;
          }
        }
      }
  for (int i = 1; i <= la; i++)
    for (int j = 1; j <= lb; j++)
      for (int k = 0; k < lc; k++)
        if (f[i][j][k] > f[ansi][ansj][ansk]) {
          ansi = i, ansj = j, ansk = k;
        }
  len = f[ansi][ansj][ansk];
  if (!len) {
    printf("0");
    return 0;
  }
  for (int w = len; w;) {
    int ti = prei[ansi][ansj][ansk], tj = prej[ansi][ansj][ansk],
        tk = prek[ansi][ansj][ansk];
    if (f[ti][tj][tk] < f[ansi][ansj][ansk]) Ans[w--] = A[ansi];
    ansi = ti, ansj = tj, ansk = tk;
  }
  printf("%s", Ans + 1);
}