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 double eps = 1e-9;
const double pi = acos(-1.0);
int dp[111][111][111], dp2[111][111], n, m, k, p[111];
bool calced[111][111][111], calced2[111][111];
string second, t, v;
bool ok = false;
int calc(int i, int j, int first) {
  if (first >= k) return -int(2e9);
  if (i == n || j == m) return 0;
  if (calced[i][j][first]) return dp[i][j][first];
  calced[i][j][first] = true;
  int &res = dp[i][j][first];
  res = 0;
  if (second[i] == t[j]) {
    int q = first;
    while (q > 0 && v[q] != second[i]) q = p[q - 1];
    if (v[q] == second[i]) q++;
    res = max(res, calc(i + 1, j + 1, q) + 1);
  }
  res = max(res, max(calc(i + 1, j, first), calc(i, j + 1, first)));
  return res;
}
void restore(int i, int j, int first, int r) {
  if (i == n || j == m || r == 0) return;
  if (second[i] == t[j]) {
    int q = first;
    while (q > 0 && v[q] != second[i]) q = p[q - 1];
    if (v[q] == second[i]) q++;
    if (calc(i + 1, j + 1, q) + 1 == r) {
      cout << second[i];
      ok = true;
      restore(i + 1, j + 1, q, r - 1);
      return;
    }
  }
  if (calc(i + 1, j, first) == r)
    restore(i + 1, j, first, r);
  else
    restore(i, j + 1, first, r);
}
int main() {
  cin >> second >> t >> v;
  n = int((second).size());
  m = int((t).size());
  k = int((v).size());
  for (int i = 1; i < k; ++i) {
    int j = p[i - 1];
    while (j > 0 && v[i] != v[j]) j = p[j - 1];
    if (v[i] == v[j]) j++;
    p[i] = j;
  }
  int r = calc(0, 0, 0);
  restore(0, 0, 0, r);
  if (!ok) puts("0");
  return 0;
}