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 MAXN = 105;
char s1[MAXN];
char s2[MAXN];
char virus[MAXN];
int c[MAXN];
string dp[MAXN][MAXN][MAXN];
void relax(string& a, string b) {
  if (b.size() > a.size()) a = b;
}
int main(int argc, char** argv) {
  ios_base::sync_with_stdio(false);
  cin >> s1 >> s2 >> virus;
  int n1 = strlen(s1);
  int n2 = strlen(s2);
  int vl = strlen(virus);
  for (int i = 1; i < vl; ++i) {
    int j = c[i - 1];
    while (j > 0 && virus[i] != virus[j]) j = c[j - 1];
    if (virus[i] == virus[j]) ++j;
    c[i] = j;
  }
  for (int i1 = 1; i1 <= n1; ++i1)
    for (int i2 = 1; i2 <= n2; ++i2) {
      for (int k = 0; k < (int)(vl); ++k) {
        if (s1[i1 - 1] == s2[i2 - 1]) {
          char sym = s1[i1 - 1];
          int j = k;
          while (j > 0 && sym != virus[j]) j = c[j - 1];
          if (sym == virus[j]) ++j;
          relax(dp[i1][i2][j], dp[i1 - 1][i2 - 1][k] + sym);
          relax(dp[i1][i2][k], dp[i1 - 1][i2 - 1][k]);
        }
        relax(dp[i1][i2][k], dp[i1 - 1][i2][k]);
        relax(dp[i1][i2][k], dp[i1][i2 - 1][k]);
      }
    }
  string ans = "";
  for (int k = 0; k < (int)(vl); ++k) {
    relax(ans, dp[n1][n2][k]);
  }
  cout << ((ans.size() == 0) ? "0" : ans) << endl;
  return 0;
}