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;
int memo[100 + 5][100 + 5][100 + 5], b[100 + 5];
char s1[100 + 5], s2[100 + 5], s[100 + 5];
int sz1, sz2, m;
void borde() {
  b[0] = -1;
  for (int i = 1; i <= m; ++i) {
    int j = b[i - 1];
    while (j != -1 && s[j] != s[i - 1]) j = b[j];
    b[i] = j + 1;
  }
}
int next(int u, int c) {
  int j = u;
  while (j != -1 && s[j] != c) j = b[j];
  return j + 1;
}
int f(int pa, int push_back, int nodo) {
  if (pa == sz1 || push_back == sz2) return 0;
  int &ret = memo[pa][push_back][nodo];
  if (ret != -1) return ret;
  ret = 0;
  ret = max(ret, f(pa + 1, push_back, nodo));
  ret = max(ret, f(pa, push_back + 1, nodo));
  if (s1[pa] == s2[push_back]) {
    int u = next(nodo, s1[pa]);
    if (u != m) ret = max(ret, 1 + f(pa + 1, push_back + 1, u));
  }
  return ret;
}
void rec(int pa, int push_back, int nodo) {
  if (pa == sz1 || push_back == sz2) return;
  int cur = f(pa, push_back, nodo);
  if (cur == f(pa + 1, push_back, nodo)) {
    rec(pa + 1, push_back, nodo);
    return;
  }
  if (cur == f(pa, push_back + 1, nodo)) {
    rec(pa, push_back + 1, nodo);
    return;
  }
  printf("%c", s1[pa]);
  int u = next(nodo, s1[pa]);
  rec(pa + 1, push_back + 1, u);
}
int main() {
  scanf("%s%s%s", s1, s2, s);
  m = strlen(s);
  borde();
  sz1 = strlen(s1), sz2 = strlen(s2);
  memset(memo, -1, sizeof(memo));
  int ans = f(0, 0, 0);
  if (!ans)
    puts("0");
  else
    rec(0, 0, 0), puts("");
}