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 ar[110], as[110], virus[110];
int kont[110][30];
int dn[110][110][110];
int yaz[110][110][110][3];
int N, M, K;
int f(int x, int y, int z) {
  if (z == K) return -1;
  if (dn[x][y][z] != -1) return dn[x][y][z];
  int mx = 0;
  int k, tut = INT_MAX, tut2, tut3;
  for (int i = x + 1; i <= N; i++)
    for (int j = y + 1; j <= M; j++)
      if (ar[i] == as[j]) {
        k = f(i, j, kont[z][ar[i] - 'A']) + 1;
        if (k > mx) {
          mx = k;
          tut = i;
          tut2 = j;
          tut3 = kont[z][ar[i] - 'A'];
        }
      }
  yaz[x][y][z][0] = tut;
  yaz[x][y][z][1] = tut2;
  yaz[x][y][z][2] = tut3;
  return dn[x][y][z] = mx;
}
int main() {
  scanf(" %s %s %s", ar + 1, as + 1, virus + 1);
  N = strlen(ar + 1);
  M = strlen(as + 1);
  K = strlen(virus + 1);
  for (int i = 0; i <= K; i++)
    for (int j = 0; j < 26; j++) {
      int knt;
      for (int k = 0; k <= i; k++) {
        int m, l;
        knt = 0;
        for (l = k + 1, m = 1; l <= i; l++, m++)
          if (virus[l] != virus[m]) break;
        if (l == i + 1 && virus[m] == 'A' + j) {
          knt = m;
          break;
        }
      }
      kont[i][j] = knt;
    }
  memset(dn, -1, sizeof dn);
  int k;
  k = f(0, 0, 0);
  if (k == 0)
    printf("0\n");
  else {
    int k = 0, l = 0, m = 0, t, t1, t2;
    while (yaz[k][l][m][0] != INT_MAX) {
      t = yaz[k][l][m][0];
      t1 = yaz[k][l][m][1];
      t2 = yaz[k][l][m][2];
      printf("%c", ar[t]);
      k = t;
      l = t1;
      m = t2;
    }
  }
  return 0;
}