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[110][110][110], back[110], asz, bsz, vsz;
string a, b, v;
void kmpPreprocess(void) {
  int i = 0, j = -1;
  back[0] = -1;
  while (i < vsz) {
    while (j >= 0 and v[i] != v[j]) {
      j = back[j];
    }
    i++;
    j++;
    back[i] = j;
  }
}
int lcs(int i, int j, int k) {
  if (k == vsz) {
    return -1000000000;
  }
  if (i == asz or j == bsz) {
    return 0;
  }
  if (memo[i][j][k] != -1) {
    return memo[i][j][k];
  }
  int ans = 0;
  if ((a[i] == b[j])) {
    int m = k;
    while (m >= 0 and a[i] != v[m]) {
      m = back[m];
    }
    ans = max(ans, 1 + lcs(i + 1, j + 1, m + 1));
  }
  ans = max(ans, lcs(i + 1, j, k));
  ans = max(ans, lcs(i, j + 1, k));
  memo[i][j][k] = ans;
  return ans;
}
void printPath(int i, int j, int k) {
  if (i == asz or j == bsz or k == vsz) {
    return;
  }
  if ((a[i] == b[j])) {
    int m = k;
    while (m >= 0 and a[i] != v[m]) {
      m = back[m];
    }
    if (memo[i][j][k] == 1 + lcs(i + 1, j + 1, m + 1)) {
      cout << a[i];
      printPath(i + 1, j + 1, m + 1);
      return;
    }
  }
  if (memo[i][j][k] == lcs(i + 1, j, k)) {
    printPath(i + 1, j, k);
  } else if (memo[i][j][k] == lcs(i, j + 1, k)) {
    printPath(i, j + 1, k);
  }
}
int main(void) {
  while (cin >> a >> b >> v) {
    asz = a.size();
    bsz = b.size();
    vsz = v.size();
    memset(memo, -1, sizeof(memo));
    kmpPreprocess();
    int ans = lcs(0, 0, 0);
    if (ans == 0) {
      cout << ans << endl;
    } else {
      printPath(0, 0, 0);
      cout << endl;
    }
  }
  return 0;
}