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 long long mod = 1000000007;
const long long inf = LLONG_MAX;
const long long ninf = LLONG_MIN;
const long double eps = 1e-12;
const long long N = 1000005;
const long long LOGN = 19;
string s1, s2, virus;
vector<long long> pi;
string dp[105][105][105];
bool done[105][105][105];
vector<long long> KMP(string second) {
  vector<long long> p(second.size());
  long long j = 0;
  for (long long i = 1; i < (long long)second.size(); i++) {
    while (j > 0 && second[j] != second[i]) j = p[j - 1];
    if (second[j] == second[i]) j++;
    p[i] = j;
  }
  return p;
}
string best(string a, string b) {
  if (a.size() < b.size()) return b;
  return a;
}
string solve(long long i, long long j, long long k) {
  if (i == s1.size() || j == s2.size()) return "";
  if (done[i][j][k]) return dp[i][j][k];
  done[i][j][k] = true;
  string ret = "";
  ret = best(ret, solve(i + 1, j, k));
  ret = best(ret, solve(i, j + 1, k));
  if (s1[i] == s2[j]) {
    char c = s1[i];
    if (c == virus[k] && k != virus.size() - 1) {
      ret = best(ret, c + solve(i + 1, j + 1, k + 1));
    } else if (c != virus[k]) {
      long long next = 0;
      if (k != 0) {
        string tmp = virus.substr(0, k);
        tmp = tmp + c;
        pi = KMP(tmp);
        next = pi[tmp.size() - 1];
      }
      ret = best(ret, c + solve(i + 1, j + 1, next));
    }
  }
  dp[i][j][k] = ret;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> s1 >> s2 >> virus;
  memset(done, false, sizeof(done));
  pi = KMP(virus);
  string ans = solve(0, 0, 0);
  if (ans.size())
    cout << ans << "\n";
  else
    cout << "0\n";
  return 0;
}