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;
string S1, S2, V;
string dp[100 + 1][100 + 1][100];
int aux[100][26];
vector<int> aux2[100];
bool tozero[100][26];
int main() {
  cin >> S1 >> S2 >> V;
  int size1 = S1.size();
  int size2 = S2.size();
  int sizeV = V.size();
  for (int i = 0; i < sizeV; i++) {
    for (int j = 0; j < 26; j++) {
      char c = 'A' + j;
      for (int postest = 0; postest < i; postest++) {
        if (V[i - postest] != c) {
          continue;
        }
        bool good = true;
        for (int idx = 0; idx < i - postest; idx++) {
          if (V[idx] != V[idx + postest]) {
            good = false;
            break;
          }
        }
        if (good) {
          aux[i][j] = i - postest + 1;
          break;
        }
      }
      if (aux[i][j] == 0 && c == V[0]) {
        aux[i][j] = 1;
      }
    }
  }
  for (int i = 0; i < sizeV; i++) {
    for (int j = 0; j < 26; j++) {
      if (aux[i][j] != 0 && aux[i][j] != sizeV) {
        aux2[aux[i][j]].push_back(i);
      } else if (aux[i][j] == 0) {
        tozero[i][j] = true;
      }
    }
  }
  string ans = "";
  for (int i = 1; i <= size1; i++) {
    for (int j = 1; j <= size2; j++) {
      for (int k = 0; k < sizeV; k++) {
        if (dp[i - 1][j][k].size() > dp[i][j - 1][k].size()) {
          dp[i][j][k] = dp[i - 1][j][k];
        } else {
          dp[i][j][k] = dp[i][j - 1][k];
        }
        if (k == 0) {
          if (S1[i - 1] == S2[j - 1] && S1[i - 1] != V[0]) {
            for (int from = 0; from < sizeV; from++) {
              if (tozero[from][S1[i - 1] - 'A']) {
                string next = dp[i - 1][j - 1][from] + string(1, S1[i - 1]);
                if (next.size() > dp[i][j][k].size()) {
                  dp[i][j][k] = next;
                }
              }
            }
          }
        } else {
          if (S1[i - 1] == S2[j - 1] && S1[i - 1] == V[k - 1]) {
            for (int from : aux2[k]) {
              string next = dp[i - 1][j - 1][from] + string(1, V[k - 1]);
              if (next.size() > dp[i][j][k].size()) {
                dp[i][j][k] = next;
              }
            }
          }
        }
        if (dp[i][j][k].size() > ans.size()) {
          ans = dp[i][j][k];
        }
      }
    }
  }
  if (ans.size() != 0) {
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}