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>
int ls, lt, lv, cnt;
int dp[102][102][102], next[102];
char s[102], t[102], v[102], ans[102];
struct Path {
  short int i, j, k;
  char c;
  inline void set(short int _i, short int _j, short int _k, char _c) {
    i = _i;
    j = _j;
    k = _k;
    c = _c;
  }
} path[102][102][102], ansp;
void getNext() {
  int j = 1, k = 0;
  next[0] = 0;
  while (j <= lv) {
    if (k == 0 || v[j] == v[k])
      next[++j] = ++k;
    else
      k = next[k];
  }
}
bool solve() {
  int i, j, k, l, mxlen = -1;
  bool ok;
  memset(dp, 0, sizeof(dp));
  for (i = 1; i <= ls; i++)
    for (j = 1; j <= lt; j++) {
      ok = (s[i] == t[j]);
      for (k = 0; k < lv && k <= i && k <= j; k++) {
        if (dp[i][j][k] < dp[i - 1][j][k])
          path[i][j][k].set(i - 1, j, k, 0), dp[i][j][k] = dp[i - 1][j][k];
        if (dp[i][j][k] < dp[i][j - 1][k])
          dp[i][j][k] = dp[i][j - 1][k], path[i][j][k].set(i, j - 1, k, 0);
        if (ok) {
          l = k + 1;
          while (l && v[l] != s[i]) l = next[l];
          if (dp[i][j][l] < dp[i - 1][j - 1][k] + 1)
            dp[i][j][l] = dp[i - 1][j - 1][k] + 1,
            path[i][j][l].set(i - 1, j - 1, k, s[i]);
        }
      }
      for (k = 0; k < lv; k++)
        if (mxlen < dp[i][j][k]) mxlen = dp[i][j][k], ansp.set(i, j, k, 0);
    }
  if (mxlen == 0) return 0;
  cnt = 0;
  Path t = ansp;
  while (t.i && t.j) {
    if (t.c) ans[++cnt] = t.c;
    t = path[t.i][t.j][t.k];
  }
  if (t.c) ans[++cnt] = t.c;
  return 1;
}
int main() {
  int i;
  s[0] = t[0] = v[0] = '#';
  while (~scanf("%s %s %s", s + 1, t + 1, v + 1)) {
    ls = strlen(s) - 1;
    lt = strlen(t) - 1;
    lv = strlen(v) - 1;
    getNext();
    if (solve()) {
      for (i = cnt; i; i--) printf("%c", ans[i]);
      puts("");
    } else
      puts("0");
  }
  return 0;
}