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 = 200, M = 26, INF = 1e15;
long long n, m, w, tnod = 1, f[N], nxt[N][M + 4], virnod;
string s, t, vir;
pair<long long, string> ans, dp[N][N][N];
queue<long long> q;
void insertt() {
  long long ind = 0;
  for (char c : vir) {
    if (nxt[ind][c - 'A'] == 0) nxt[ind][c - 'A'] = tnod++;
    ind = nxt[ind][c - 'A'];
  }
  virnod = ind;
}
void aho() {
  long long x;
  for (int i = 0; i < M; i++)
    if (nxt[0][i]) q.push(nxt[0][i]);
  while (!q.empty()) {
    x = q.front(), q.pop();
    for (int i = 0; i < 26; i++) {
      if (nxt[x][i] != 0) {
        f[nxt[x][i]] = nxt[f[x]][i];
        q.push(nxt[x][i]);
      } else
        nxt[x][i] = nxt[f[x]][i];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> s >> t >> vir;
  n = s.size(), m = t.size(), w = vir.size();
  insertt();
  aho();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (s[i - 1] == t[j - 1]) {
        for (int l = 0; l < tnod; l++) {
          if (nxt[l][s[i - 1] - 'A'] == virnod || l == virnod) continue;
          if (dp[i - 1][j - 1][l].first >=
              dp[i][j][nxt[l][s[i - 1] - 'A']].first) {
            dp[i][j][nxt[l][s[i - 1] - 'A']].first =
                dp[i - 1][j - 1][l].first + 1;
            dp[i][j][nxt[l][s[i - 1] - 'A']].second =
                dp[i - 1][j - 1][l].second + s[i - 1];
          }
        }
      }
      for (int l = 0; l < tnod; l++) {
        if (l == virnod) continue;
        if (dp[i][j - 1][l].first > dp[i][j][l].first)
          dp[i][j][l] = dp[i][j - 1][l];
        if (dp[i - 1][j][l].first > dp[i][j][l].first)
          dp[i][j][l] = dp[i - 1][j][l];
      }
    }
  }
  ans = {-INF, ""};
  for (int i = 0; i < tnod; i++)
    if (i != virnod) ans = max(ans, dp[n][m][i]);
  if (ans.first == 0) cout << 0;
  if (ans.first != 0) cout << ans.second;
  return 0;
}