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 N = 1e2 + 5, alfa = 100;
string str1, str2, str3;
int b[N], autom[N][alfa], resp, posi, dp[N][N][N];
vector<char> vec;
void prekmp(string &s) {
  for (int i = 1; i < s.size(); i++) {
    int j = b[i - 1];
    while (j > 0 && s[i] != s[j]) j = b[j - 1];
    if (s[i] == s[j]) j++;
    b[i] = j;
  }
}
void automato(string &str) {
  autom[0][str[0] - 'A'] = 1;
  for (int i = 1; i <= str.size(); i++) {
    for (int c = 0; c < alfa; c++) {
      if (i < str.size() && str[i] == (char)(c + 'A'))
        autom[i][c] = i + 1;
      else
        autom[i][c] = autom[b[i - 1]][c];
    }
  }
}
int LCS(int i, int j, int pos) {
  if (i == 0 || j == 0) return dp[i][j][pos] = 0;
  if (dp[i][j][pos] != -1) return dp[i][j][pos];
  if (str1[i - 1] == str2[j - 1]) {
    for (int p = 0; p < str3.size(); p++)
      if (autom[p][str1[i - 1] - 'A'] == pos)
        dp[i][j][pos] = max(dp[i][j][pos], LCS(i - 1, j - 1, p) + 1);
  }
  dp[i][j][pos] =
      max(dp[i][j][pos], max(LCS(i, j - 1, pos), LCS(i - 1, j, pos)));
  return dp[i][j][pos];
}
void build(int i, int j, int pos) {
  if (i == 0 || j == 0) return;
  if (str1[i - 1] == str2[j - 1]) {
    for (int p = 0; p < str3.size(); p++)
      if (autom[p][str1[i - 1] - 'A'] == pos &&
          dp[i][j][pos] == dp[i - 1][j - 1][p] + 1) {
        vec.push_back(str1[i - 1]), build(i - 1, j - 1, p);
        return;
      }
  }
  if (dp[i][j][pos] == dp[i][j - 1][pos]) {
    build(i, j - 1, pos);
    return;
  }
  if (dp[i][j][pos] == dp[i - 1][j][pos]) {
    build(i - 1, j, pos);
    return;
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> str1 >> str2 >> str3;
  memset(dp, -1, sizeof(dp)), prekmp(str3), automato(str3);
  for (int i = 0; i < str3.size(); i++)
    if (resp < LCS(str1.size(), str2.size(), i))
      posi = i, resp = LCS(str1.size(), str2.size(), i);
  build(str1.size(), str2.size(), posi);
  if (!resp)
    cout << resp << "\n";
  else {
    for (int i = vec.size() - 1; i >= 0; i--) cout << vec[i];
    cout << "\n";
  }
}