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 M = 105;
int n1, n2, m;
char A[M], B[M], ptr[M];
int xei[M];
void Init_xei() {
  xei[0] = xei[1] = 0;
  for (int i = 2, pos = 1; i <= m;) {
    while (pos <= m && ptr[pos] == ptr[i + pos - 1])
      xei[i + pos - 1] = pos, pos++;
    pos--;
    if (pos == 0)
      i++, pos = 1;
    else
      i += pos - xei[pos], pos = xei[pos] + 1;
  }
}
struct node {
  int val;
  bool cho;
  int La, Lb, Lptr;
} dp[M][M][M];
void Dp() {
  for (int i = 0; i <= n1; i++)
    for (int j = 0; j <= n2; j++)
      for (int q = 0; q < m; q++) {
        node &d = dp[i][j][q], &di = dp[i + 1][j][q], &dj = dp[i][j + 1][q];
        if (di.val < d.val)
          di.val = d.val, di.La = i, di.Lb = j, di.Lptr = q, di.cho = false;
        if (dj.val < d.val)
          dj.val = d.val, dj.La = i, dj.Lb = j, dj.Lptr = q, dj.cho = false;
        if (A[i + 1] == B[j + 1]) {
          int nx = (A[i + 1] == ptr[q + 1]
                        ? q + 1
                        : (A[i + 1] == ptr[xei[q] + 1] ? xei[q] + 1 : 0));
          node &dc = dp[i + 1][j + 1][nx];
          if (dc.val < d.val + 1)
            dc.val = d.val + 1, dc.La = i, dc.Lb = j, dc.Lptr = q,
            dc.cho = true;
        }
      }
}
void Print(int i, int j, int q) {
  if (i == 0 && j == 0 && q == 0) return;
  node &d = dp[i][j][q];
  Print(d.La, d.Lb, d.Lptr);
  if (d.cho) putchar(A[i]);
}
int main() {
  scanf("%s%s%s", A + 1, B + 1, ptr + 1);
  n1 = strlen(A + 1), n2 = strlen(B + 1), m = strlen(ptr + 1);
  Init_xei();
  Dp();
  int pos = -1, Mx = 0;
  for (int i = 0; i < m; i++)
    if (dp[n1][n2][i].val > Mx) Mx = dp[n1][n2][i].val, pos = i;
  if (pos == -1)
    puts("0");
  else
    Print(n1, n2, pos);
  return 0;
}