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 MAX_L = 110;
int An, Bn, Pn, Ansn;
char Ptr[MAX_L], A[MAX_L], B[MAX_L], Ans[MAX_L];
int P[MAX_L], F[MAX_L][MAX_L][MAX_L];
struct Triple {
  int i, j, k;
} G[MAX_L][MAX_L][MAX_L];
void GetP() {
  int i, j;
  for (P[1] = j = 0, i = 2; i <= Pn; i++) {
    while (j != 0 && Ptr[j + 1] != Ptr[i]) j = P[j];
    if (Ptr[j + 1] == Ptr[i]) j++;
    P[i] = j;
  }
}
void Construct(int i, int j, int k) {
  if (!F[i][j][k]) return;
  Triple g = G[i][j][k];
  if (g.i + 1 == i && g.j + 1 == j) Ans[++Ansn] = A[i];
  Construct(g.i, g.j, g.k);
}
inline void Main() {
  scanf("%s%s%s", A + 1, B + 1, Ptr + 1);
  An = strlen(A + 1), Bn = strlen(B + 1), Pn = strlen(Ptr + 1);
  GetP();
  for (int i = 0; i <= An; i++)
    for (int j = 0; j <= Bn; j++)
      for (int k = 0; k < Pn; k++) {
        int f = F[i][j][k];
        if (f > F[i + 1][j][k])
          F[i + 1][j][k] = f, G[i + 1][j][k] = (Triple){i, j, k};
        if (f > F[i][j + 1][k])
          F[i][j + 1][k] = f, G[i][j + 1][k] = (Triple){i, j, k};
        if (A[i + 1] == B[j + 1]) {
          char c = A[i + 1];
          if (c == Ptr[k + 1]) {
            if (f + 1 > F[i + 1][j + 1][k + 1])
              F[i + 1][j + 1][k + 1] = f + 1,
                                  G[i + 1][j + 1][k + 1] = (Triple){i, j, k};
          } else {
            int nxt = k;
            while (nxt != 0 && Ptr[nxt + 1] != c) nxt = P[nxt];
            if (Ptr[nxt + 1] == c) nxt++;
            if (f + 1 > F[i + 1][j + 1][nxt])
              F[i + 1][j + 1][nxt] = f + 1,
                           G[i + 1][j + 1][nxt] = (Triple){i, j, k};
          }
        }
      }
  int ans = -1, bestk = -1;
  for (int k = 0; k < Pn; k++)
    if (F[An][Bn][k] > ans) ans = F[An][Bn][k], bestk = k;
  assert(~ans), assert(~bestk);
  if (!ans)
    puts("0");
  else {
    Construct(An, Bn, bestk);
    for (int i = Ansn; i >= 1; i--) putchar(Ans[i]);
    puts("");
  }
}
int main() {
  Main();
  return 0;
}