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 ch[111];
int i, j, k, n, m, w, g[111], f[111][111][111], p[111][111][111][3], a[111],
    b[111], c[111], t, ans, q[111], st[3], st2[3];
int work(int p, int x) {
  for (; p && c[p + 1] != x; p = g[p])
    ;
  return c[p + 1] == x ? p + 1 : p;
}
int main() {
  scanf("%s", ch);
  for (i = 1, n = strlen(ch); i <= n; i++) a[i] = ch[i - 1] - 'a' + 1;
  scanf("%s", ch);
  for (i = 1, m = strlen(ch); i <= m; i++) b[i] = ch[i - 1] - 'a' + 1;
  scanf("%s", ch);
  for (i = 1, w = strlen(ch); i <= w; i++) c[i] = ch[i - 1] - 'a' + 1;
  for (i = 2, j = g[1] = 0; i <= w; i++) {
    for (; j && c[i] != c[j + 1]; j = g[j])
      ;
    if (c[i] == c[j + 1]) j++;
    g[i] = j;
  }
  memset(f, 0, sizeof(f));
  for (i = 0; i <= n; i++)
    for (j = 0; j <= m; j++)
      for (k = 0; k <= min(min(i, j), w - 1); k++) {
        if (a[i + 1] == b[j + 1]) {
          t = work(k, a[i + 1]);
          if (f[i][j][k] + 1 > f[i + 1][j + 1][t])
            f[i + 1][j + 1][t] = f[i][j][k] + 1, p[i + 1][j + 1][t][0] = i,
                         p[i + 1][j + 1][t][1] = j, p[i + 1][j + 1][t][2] = k;
        }
        if (f[i][j][k] > f[i + 1][j][k])
          f[i + 1][j][k] = f[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 (f[i][j][k] > f[i][j + 1][k])
          f[i][j + 1][k] = f[i][j][k], p[i][j + 1][k][0] = i,
                   p[i][j + 1][k][1] = j, p[i][j + 1][k][2] = k;
        f[i + 1][j][k] = max(f[i + 1][j][k], f[i][j][k]);
        f[i][j + 1][k] = max(f[i][j + 1][k], f[i][j][k]);
      }
  for (ans = i = 0; i < w; i++)
    if (f[n][m][i] > ans) ans = f[n][m][i], st[2] = i;
  for (st[0] = n, st[1] = m, q[0] = 0; f[st[0]][st[1]][st[2]];) {
    memcpy(st2, p[st[0]][st[1]][st[2]], sizeof(st2));
    if (f[st[0]][st[1]][st[2]] > f[st2[0]][st2[1]][st2[2]])
      q[++q[0]] = a[st[0]];
    memcpy(st, st2, sizeof(st));
  }
  if (ans == 0) {
    puts("0");
    return 0;
  }
  for (i = q[0]; i; i--) printf("%c", q[i] + 'a' - 1);
  puts("");
  return 0;
}