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>
char s[109], t[109], v[109];
int h[109];
int n, m, l;
int f[109][109][109], g[109][109][109];
char res[109];
int main() {
  gets(s + 1);
  n = strlen(s + 1);
  gets(t + 1);
  m = strlen(t + 1);
  gets(v + 1);
  l = strlen(v + 1);
  for (int i = 2, k = 0; i <= l; i++) {
    while (k > 0 && v[k + 1] != v[i]) k = h[k];
    if (v[k + 1] == v[i]) k++;
    h[i] = k;
  }
  memset(f, -1, sizeof(f));
  f[0][0][0] = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      for (int k = 0; k <= l; k++)
        if (f[i][j][k] >= 0) {
          if (f[i + 1][j][k] < f[i][j][k]) {
            f[i + 1][j][k] = f[i][j][k];
            g[i + 1][j][k] = ((i * 109) + j) * 109 + k;
          }
          if (f[i][j + 1][k] < f[i][j][k]) {
            f[i][j + 1][k] = f[i][j][k];
            g[i][j + 1][k] = ((i * 109) + j) * 109 + k;
          }
          if (s[i + 1] == t[j + 1]) {
            int K = k;
            while (K > 0 && v[K + 1] != s[i + 1]) K = h[K];
            if (v[K + 1] == s[i + 1]) K++;
            if (K < l)
              if (f[i + 1][j + 1][K] < f[i][j][k] + 1) {
                f[i + 1][j + 1][K] = f[i][j][k] + 1;
                g[i + 1][j + 1][K] = ((i * 109) + j) * 109 + k;
              }
          }
        }
  int I = n, J = m, K, mx = -1;
  for (int k = 0; k <= l; k++) {
    if (f[n][m][k] > mx) K = k, mx = f[n][m][k];
  }
  if (mx == 0) {
    puts("0");
    return 0;
  }
  res[mx] = 0;
  while (I) {
    int i = I, j = J, k = K;
    I = g[i][j][k] / 109 / 109;
    J = (g[i][j][k] / 109) % 109;
    K = g[i][j][k] % 109;
    if (f[i][j][k] != f[I][J][K]) res[--mx] = t[j];
  }
  puts(res);
}