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 s1[105], s2[105], s3[105];
int n1, n2, n3;
int fail[105], d[105][105][105];
int biu[105][105][105][3] = {0};
void clr() { memset(d, 0, sizeof(d)); }
void findsub(int i, int j, int k) {
  if (i == 0 && j == 0 && k == 0) return;
  int a = biu[i][j][k][0];
  int b = biu[i][j][k][1];
  int c = biu[i][j][k][2];
  findsub(a, b, c);
  if (d[a][b][c] + 1 == d[i][j][k]) printf("%c", s1[a]);
}
void sov() {
  for (int j = 0, i = 1; i < n3; i++) {
    while (j > 0 && s3[i] != s3[j]) j = fail[j - 1];
    if (s3[i] == s3[j]) j++;
    fail[i] = j;
  }
  for (int i = 0; i <= n1; i++)
    for (int j = 0; j <= n2; j++)
      for (int k = 0; k < n3; k++) {
        if (d[i][j][k] > d[i + 1][j][k]) {
          d[i + 1][j][k] = d[i][j][k];
          biu[i + 1][j][k][0] = i, biu[i + 1][j][k][1] = j,
                  biu[i + 1][j][k][2] = k;
        }
        if (d[i][j][k] > d[i][j + 1][k]) {
          d[i][j + 1][k] = d[i][j][k];
          biu[i][j + 1][k][0] = i, biu[i][j + 1][k][1] = j,
                     biu[i][j + 1][k][2] = k;
        }
        if (s1[i] == s2[j]) {
          int f = k;
          while (f && s1[i] != s3[f]) f = fail[f - 1];
          if (s1[i] == s3[f])
            f++;
          else
            f = 0;
          if (d[i + 1][j + 1][f] < d[i][j][k] + 1) {
            d[i + 1][j + 1][f] = d[i][j][k] + 1;
            biu[i + 1][j + 1][f][0] = i;
            biu[i + 1][j + 1][f][1] = j;
            biu[i + 1][j + 1][f][2] = k;
          }
        }
      }
  int ans = 0, q = 0;
  for (int i = 0; i < n3; i++)
    if (ans < d[n1][n2][i]) ans = d[n1][n2][i], q = i;
  if (!ans)
    printf("0");
  else
    findsub(n1, n2, q);
}
int main() {
  scanf("%s%s%s", s1, s2, s3);
  n1 = strlen(s1);
  n2 = strlen(s2);
  n3 = strlen(s3);
  clr();
  sov();
  return 0;
}