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[1000], s2[1000], v[1000], s[1000];
int d[200][200][200];
int p[200][200][200][3];
int pp[1000];
int main() {
  int i, j, k, l1, l2, l, tmp, ans, bk, ti, tj, tk, m;
  scanf("%s%s%s", s1, s2, v);
  l1 = strlen(s1);
  l2 = strlen(s2);
  l = strlen(v);
  pp[0] = 0;
  pp[1] = 0;
  i = 0;
  j = 1;
  while (1) {
    if (j == l) break;
    pp[j] = i;
    while ((i > 0) && (v[i] != v[j])) i = pp[i];
    if (v[i] == v[j]) {
      i++;
      j++;
    } else
      j++;
  }
  memset(d, -1, sizeof(d));
  d[0][0][0] = 0;
  for (i = 0; i <= l1; i++)
    for (j = 0; j <= l2; j++)
      for (k = 0; k < l; k++)
        if (d[i][j][k] != -1) {
          if (i < l1)
            if (d[i][j][k] > d[i + 1][j][k]) {
              d[i + 1][j][k] = d[i][j][k];
              p[i + 1][j][k][0] = i;
              p[i + 1][j][k][1] = j;
              p[i + 1][j][k][2] = k;
            }
          if (j < l2)
            if (d[i][j][k] > d[i][j + 1][k]) {
              d[i][j + 1][k] = d[i][j][k];
              p[i][j + 1][k][0] = i;
              p[i][j + 1][k][1] = j;
              p[i][j + 1][k][2] = k;
            }
          if ((i < l1) && (j < l2) && (s1[i] == s2[j])) {
            tmp = k;
            while ((tmp > 0) && (v[tmp] != s1[i])) tmp = pp[tmp];
            if (v[tmp] == s1[i]) tmp++;
            if (tmp < l) {
              if (d[i][j][k] + 1 > d[i + 1][j + 1][tmp]) {
                d[i + 1][j + 1][tmp] = d[i][j][k] + 1;
                p[i + 1][j + 1][tmp][0] = i;
                p[i + 1][j + 1][tmp][1] = j;
                p[i + 1][j + 1][tmp][2] = k;
              }
            }
          }
        }
  ans = -1;
  for (k = 0; k < l; k++)
    if (d[l1][l2][k] > ans) {
      ans = d[l1][l2][k];
      bk = k;
    }
  if (ans == 0)
    printf("0\n");
  else {
    m = 0;
    ti = l1;
    tj = l2;
    tk = bk;
    while ((ti != 0) || (tj != 0)) {
      i = p[ti][tj][tk][0];
      j = p[ti][tj][tk][1];
      k = p[ti][tj][tk][2];
      if ((i < ti) && (j < tj)) {
        s[m] = s1[i];
        m++;
      }
      ti = i;
      tj = j;
      tk = k;
    }
    s[m] = '\0';
    reverse(s, s + m);
    printf("%s\n", s);
  }
}