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;
template <typename input_type>
input_type input() {
  input_type inp;
  cin >> inp;
  return inp;
}
const int max_sz = (1e2 + 5);
string ans, dp[max_sz][max_sz][max_sz];
int kmp[max_sz];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  pair<string, string> inp = {input<string>(), input<string>()};
  string vrs = input<string>();
  int tmp = 0;
  for (int i = 1; i < vrs.size(); i++) {
    while (tmp and (vrs[i] != vrs[tmp])) {
      tmp = kmp[tmp - 1];
    }
    if (vrs[i] == vrs[tmp]) {
      kmp[i] = ++tmp;
    }
  }
  for (int i = 1; i <= inp.first.size(); i++) {
    for (int j = 1; j <= inp.second.size(); j++) {
      for (int k = 0; k < vrs.size(); k++) {
        if (inp.first[i - 1] == inp.second[j - 1]) {
          char chr = inp.first[i - 1];
          tmp = k;
          while (tmp and (chr != vrs[tmp])) {
            tmp = kmp[tmp - 1];
          }
          if (chr == vrs[tmp]) {
            tmp++;
          }
          if (dp[i][j][tmp].size() < dp[i - 1][j - 1][k].size() + 1) {
            dp[i][j][tmp] = dp[i - 1][j - 1][k] + chr;
          }
        }
        if (dp[i][j][k].size() < dp[i - 1][j][k].size()) {
          dp[i][j][k] = dp[i - 1][j][k];
        }
        if (dp[i][j][k].size() < dp[i][j - 1][k].size()) {
          dp[i][j][k] = dp[i][j - 1][k];
        }
      }
    }
  }
  for (int i = 0; i < vrs.size(); i++) {
    if (ans.size() < dp[inp.first.size()][inp.second.size()][i].size()) {
      ans = dp[inp.first.size()][inp.second.size()][i];
    }
  }
  if (ans.size() == 0) {
    cout << 0;
  } else {
    cout << ans;
  }
  return 0;
}