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 up, down, virus;
int uplen, dnlen, vilen;
string dp[101][101][101];
int par[101];
void KPM() {
  int k = 0;
  for (int i = 1; i < virus.size(); i++) {
    while (k > 0 && virus[i] != virus[k]) k = par[k - 1];
    if (virus[i] == virus[k]) k++;
    par[i] = k;
  }
  return;
}
string MM_max(string a, string b) {
  if (a.size() == b.size()) {
    if (a < b) return a;
    return b;
  }
  if (a.size() > b.size()) return a;
  return b;
}
string rec(int upind, int dnind, int virind) {
  if (upind == uplen || dnind == dnlen) {
    return "";
  }
  string &ret = dp[upind][dnind][virind];
  if (ret != "-1") return ret;
  ret = "";
  if (up[upind] == down[dnind]) {
    if (up[upind] == virus[virind]) {
      if (virind < vilen - 1)
        ret = MM_max(ret, up[upind] + rec(upind + 1, dnind + 1, virind + 1));
    } else {
      int k = virind;
      while (k > 0 && up[upind] != virus[k]) k = par[k - 1];
      if (up[upind] == virus[k]) k++;
      ret = MM_max(ret, up[upind] + rec(upind + 1, dnind + 1, k));
    }
  }
  {
    ret = MM_max(ret, rec(upind + 1, dnind, virind));
    ret = MM_max(ret, rec(upind, dnind + 1, virind));
  }
  return ret;
}
int main() {
  cin >> up >> down >> virus;
  uplen = (int)up.size();
  dnlen = (int)down.size();
  vilen = (int)virus.size();
  for (int i = 0; i < 101; i++)
    for (int j = 0; j < 101; j++)
      for (int k = 0; k < 101; k++) dp[i][j][k] = "-1";
  KPM();
  string ans = rec(0, 0, 0);
  if (ans == "") ans = "0";
  cout << ans << endl;
  return 0;
}