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;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, 1, -1};
string s, t, ban;
int la, lb, lban;
int fail[110][30];
string dp[110][110][110];
string ans = "";
int l = 0;
int main() {
  cin >> s >> t >> ban;
  la = s.size();
  lb = t.size();
  lban = ban.size();
  string a = "";
  for (int i = (0); i < (lban + 1); ++i) {
    if (i > 0) a.push_back(ban[i - 1]);
    for (int j = (0); j < (26); ++j) {
      string b = a;
      b.push_back(j + 'A');
      int mi = min<int>(b.size(), lban);
      string emp = "";
      for (int k = 1; k <= mi; ++k) {
        emp.push_back(ban[k - 1]);
        if (emp == b.substr((int)b.size() - k, k)) fail[i][j] = k;
      }
    }
  }
  for (int i = (0); i < (la); ++i) {
    for (int j = (0); j < (lb); ++j) {
      if (s[i] == t[j]) {
        for (int k = (0); k < (lban); ++k) {
          string cur = dp[i][j][k];
          if (dp[i + 1][j + 1][k].size() < cur.size())
            dp[i + 1][j + 1][k] = cur;
          if (cur.size() == 0 && k > 0) continue;
          if (s[i] == ban[k]) {
            dp[i + 1][j + 1][k + 1] = cur + ban[k];
          } else {
            if ((int)dp[i + 1][j + 1][fail[k][s[i] - 'A']].size() <
                (int)cur.size() + 1)
              dp[i + 1][j + 1][fail[k][s[i] - 'A']] = cur + s[i];
          }
        }
      } else {
        for (int k = (0); k < (lban); ++k) {
          if (dp[i][j + 1][k].size() == 0 && dp[i + 1][j][k].size() == 0)
            continue;
          int len = 0;
          string now = "";
          if (dp[i][j + 1][k] != "") {
            len = dp[i][j + 1][k].size();
            now = dp[i][j + 1][k];
          }
          if (dp[i + 1][j][k] != "") {
            if (dp[i + 1][j][k].size() > len) now = dp[i + 1][j][k];
          }
          dp[i + 1][j + 1][k] = now;
        }
      }
    }
  }
  for (int k = (0); k < (lban); ++k) {
    if ((int)dp[la][lb][k].size() > l) {
      l = dp[la][lb][k].size();
      ans = dp[la][lb][k];
    }
  }
  if (l == 0)
    cout << "0" << endl;
  else
    cout << ans << endl;
  return 0;
}