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, K, p[105][26], f[105][105][105], g[105][105][105][3];
char A[105], B[105], C[105], s[105];
void init() {
  scanf("%s%s%s", A + 1, B + 1, C + 1), N = strlen(A + 1), M = strlen(B + 1),
                                        K = strlen(C + 1);
  for (int i = 0; i < K; i++)
    for (int j = 0; j < 26; j++) {
      for (int k = i + 1; k; k--)
        if (C[k] == j + 65) {
          bool ok = 1;
          for (int l = k; ok && l > 1; l--)
            if (C[l - 1] != C[i - (k - l)]) ok = 0;
          if (ok) {
            p[i][j] = k;
            break;
          }
        }
    }
}
inline void up(int i, int j, int k, int ii, int jj, int kk, int d) {
  if (f[i][j][k] + d > f[ii][jj][kk])
    f[ii][jj][kk] = f[i][j][k] + d, g[ii][jj][kk][0] = i, g[ii][jj][kk][1] = j,
    g[ii][jj][kk][2] = k;
}
void doit() {
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= M; j++)
      for (int k = 0; k < K; k++) {
        up(i - 1, j, k, i, j, k, 0), up(i, j - 1, k, i, j, k, 0);
        if (A[i] == B[j]) up(i - 1, j - 1, k, i, j, p[k][A[i] - 65], 1);
      }
  int t, m = 0, n = 0;
  for (int i = 0; i < K; i++)
    if (f[N][M][i] > m) t = i, m = f[N][M][i];
  if (!m) {
    puts("0");
    return;
  }
  for (int i = N, j = M, k = t; i || j;) {
    int ii = g[i][j][k][0], jj = g[i][j][k][1], kk = g[i][j][k][2];
    if (f[i][j][k] == f[ii][jj][kk] + 1) s[++n] = A[i];
    i = ii, j = jj, k = kk;
  }
  for (int i = n; i; i--) putchar(s[i]);
  puts("");
}
int main() {
  init();
  doit();
  return 0;
}