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 int inf = 9e18;
vector<long long int> lpsarray(string pat) {
  long long int M = (int)((pat).size());
  vector<long long int> lps((int)((pat).size()), 0);
  int len = 0;
  lps[0] = 0;
  int i = 1;
  while (i < M) {
    if (pat[i] == pat[len]) {
      len++;
      lps[i] = len;
      i++;
    } else {
      if (len != 0) {
        len = lps[len - 1];
      } else {
        lps[i] = 0;
        i++;
      }
    }
  }
  return lps;
}
void trace_back(string &s, vector<long long int> &tr,
                vector<vector<vector<vector<long long int>>>> &pi) {
  if (pi[tr[0]][tr[1]][tr[2]][0] != -1) {
    trace_back(s, pi[tr[0]][tr[1]][tr[2]], pi);
  }
  cout << s[tr[0]];
}
int main() {
  string s1, s2, virus;
  cin >> s1 >> s2 >> virus;
  vector<long long int> util = lpsarray(virus);
  vector<vector<vector<long long int>>> dp(
      1e2 + 4, vector<vector<long long int>>(
                   1e2 + 4, vector<long long int>(1e2 + 4, 0)));
  vector<vector<vector<vector<long long int>>>> pi(
      1e2 + 4, vector<vector<vector<long long int>>>(
                   1e2 + 4, vector<vector<long long int>>(
                                1e2 + 4, vector<long long int>(3, -1))));
  vector<vector<long long int>> atka(1e2 + 4, vector<long long int>(26));
  for (int i = 0; i <= (int)((virus).size()) - 1; i++) {
    for (int j = 0; j <= 25; j++) {
      if (j + 'A' == virus[i]) {
        atka[i][j] = i + 1;
      } else {
        if (i > 0)
          atka[i][j] = atka[util[i - 1]][j];
        else {
          atka[i][j] = 0;
        }
      }
    }
  }
  for (int i = 1; i <= (int)((s1).size()); i++) {
    for (int j = 1; j <= (int)((s2).size()); j++) {
      for (int k = 0; k <= (int)((virus).size()) - 1; k++) {
        if (s1[i - 1] == s2[j - 1]) {
          if (dp[i][j][atka[k][s1[i - 1] - 'A']] < dp[i - 1][j - 1][k] + 1) {
            dp[i][j][atka[k][s1[i - 1] - 'A']] = dp[i - 1][j - 1][k] + 1;
            pi[i][j][atka[k][s1[i - 1] - 'A']] = {i - 1, j - 1, k};
          }
        }
        if (dp[i][j][k] < dp[i - 1][j][k]) {
          dp[i][j][k] = dp[i - 1][j][k];
          pi[i][j][k] = pi[i - 1][j][k];
        }
        if (dp[i][j][k] < dp[i][j - 1][k]) {
          dp[i][j][k] = dp[i][j - 1][k];
          pi[i][j][k] = pi[i][j - 1][k];
        }
      }
    }
  }
  vector<long long int> ans(3, -1);
  long long int ans1 = 0;
  for (int i = 0; i <= (int)((virus).size()) - 1; i++) {
    if (dp[(int)((s1).size())][(int)((s2).size())][i] > ans1) {
      ans1 = dp[(int)((s1).size())][(int)((s2).size())][i];
      ans = pi[(int)((s1).size())][(int)((s2).size())][i];
    }
  }
  if (ans1 == 0) {
    cout << 0 << "\n";
    return 0;
  }
  trace_back(s1, ans, pi);
}