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 int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const long long int LINF = (long long int)1e18;
const int mx = 101;
int dp[mx][mx][mx];
string ans[mx][mx][mx];
int tot[mx][30];
string a, b, v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> a >> b >> v;
  int n = a.size();
  int m = b.size();
  for (int i = 0; i < v.size() - 1; ++i) {
    for (int j = 0; j < 26; ++j) {
      string second = v.substr(0, i + 1);
      second += (char)(j + 65);
      for (int k = 0; k < second.size(); ++k) {
        if (second.substr(k) == v.substr(0, second.size() - k)) {
          tot[i + 1][j] = max(tot[i + 1][j], (int)second.size() - k);
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      for (int k = 0; k < v.size(); ++k) {
        if (a[i] == b[j]) {
          if (v[k] == a[i]) {
            if (k != v.size() - 1) {
              if (dp[i][j][k] + 1 > dp[1 + i][1 + j][1 + k]) {
                dp[i + 1][j + 1][k + 1] = dp[i][j][k] + 1;
                ans[i + 1][j + 1][k + 1] = ans[i][j][k] + a[i];
              }
            }
          } else {
            if (dp[i][j][k] + 1 > dp[i + 1][j + 1][tot[k][a[i] - 65]]) {
              dp[i + 1][j + 1][tot[k][a[i] - 65]] = dp[i][j][k] + 1;
              ans[i + 1][j + 1][tot[k][a[i] - 65]] = ans[i][j][k] + a[i];
            }
          }
        }
        if (dp[i][j][k] > dp[i + 1][j][k]) {
          dp[i + 1][j][k] = dp[i][j][k];
          ans[i + 1][j][k] = ans[i][j][k];
        }
        if (dp[i][j][k] > dp[i][j + 1][k]) {
          dp[i][j + 1][k] = dp[i][j][k];
          ans[i][j + 1][k] = ans[i][j][k];
        }
      }
    }
  }
  string res = "";
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) {
      for (int k = 0; k < v.size(); ++k) {
        if (dp[i][j][k] > res.size()) {
          res = ans[i][j][k];
        }
      }
    }
  }
  cout << res;
  if (!res.size()) cout << "0";
  return 0;
}