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 MX = 105;
int n, m, q, kmp[MX], kmp_nxt[MX][26], f[MX][MX][MX], tr[MX][MX][MX];
char s[MX], t[MX], v[MX], ans[MX];
int main() {
  scanf("%s\n%s\n%s", s + 1, t + 1, v + 1);
  n = strlen(s + 1);
  m = strlen(t + 1);
  q = strlen(v + 1);
  for (int i = 2; i <= q; i++) {
    kmp[i] = kmp[i - 1];
    while (kmp[i] != 0 && v[i] != v[kmp[i] + 1]) kmp[i] = kmp[kmp[i]];
    kmp[i] += (v[i] == v[kmp[i] + 1]);
  }
  for (int i = 0; i < q; i++)
    for (int j = 0; j < 26; j++) {
      kmp_nxt[i][j] = i;
      while (kmp_nxt[i][j] != 0 && (char)(j + 'A') != v[kmp_nxt[i][j] + 1])
        kmp_nxt[i][j] = kmp[kmp_nxt[i][j]];
      kmp_nxt[i][j] += ((char)(j + 'A') == v[kmp_nxt[i][j] + 1]);
    }
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      for (int k = 1; k < q; k++) f[i][j][k] = -1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int k = 0; k < q; k++) {
        f[i][j][k] = max(f[i - 1][j][k], f[i][j - 1][k]);
        tr[i][j][k] = -1;
        if (s[i] == t[j])
          for (int t = 0; t < q; t++)
            if (kmp_nxt[t][s[i] - 'A'] == k && f[i - 1][j - 1][t] > -1 &&
                f[i][j][k] < f[i - 1][j - 1][t] + 1) {
              f[i][j][k] = f[i - 1][j - 1][t] + 1;
              tr[i][j][k] = t;
            }
      }
  int cur = 0;
  for (int i = 1; i < q; i++)
    if (f[n][m][i] > f[n][m][cur]) cur = i;
  if (f[n][m][cur] == 0) return printf("0"), 0;
  int i = n, j = m;
  while (i > 0 && j > 0) {
    if (tr[i][j][cur] == -1) {
      if (f[i - 1][j][cur] == f[i][j][cur])
        --i;
      else
        --j;
    } else {
      ans[f[i][j][cur]] = s[i];
      cur = tr[i][j][cur];
      --i;
      --j;
    }
  }
  printf("%s", ans + 1);
}