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;
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int inf = (1 << 30) - 1;
const ll INF = (1LL << 60) - 1;
template <typename T>
bool chmax(T &x, const T &y) {
  return (x < y) ? (x = y, true) : false;
};
template <typename T>
bool chmin(T &x, const T &y) {
  return (x > y) ? (x = y, true) : false;
};
struct io_setup {
  io_setup() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(15);
  }
} io_setup;
int main() {
  string A, B, S;
  cin >> A >> B >> S;
  int N = (int)A.size(), M = (int)B.size(), K = (int)S.size();
  vector<vector<int>> nxt(K, vector<int>(26));
  for (int i = 0; i < K; i++) {
    for (int j = 0; j < 26; j++) {
      string T = S.substr(0, i);
      T += char('A' + j);
      for (int k = i + 1; k >= 0; k--) {
        if (T.substr(i + 1 - k) == S.substr(0, k)) {
          nxt[i][j] = k;
          break;
        }
      }
    }
  }
  vector<vector<vector<int>>> dp(
      N + 1, vector<vector<int>>(M + 1, vector<int>(K, -inf)));
  vector<vector<vector<int>>> pre(
      N + 1, vector<vector<int>>(M + 1, vector<int>(K, -1)));
  vector<vector<vector<int>>> pre2(
      N + 1, vector<vector<int>>(M + 1, vector<int>(K, -1)));
  dp[0][0][0] = 0;
  for (int i = 0; i < N + 1; i++) {
    for (int j = 0; j < M + 1; j++) {
      for (int k = 0; k < K; k++) {
        if (i + 1 <= N) {
          if (chmax(dp[i + 1][j][k], dp[i][j][k])) pre[i + 1][j][k] = 1;
        }
        if (j + 1 <= M) {
          if (chmax(dp[i][j + 1][k], dp[i][j][k])) pre[i][j + 1][k] = 2;
        }
        if (i + 1 <= N && j + 1 <= M) {
          if (A[i] != B[j]) continue;
          int ni = i + 1, nj = j + 1, nk = nxt[k][A[i] - 'A'];
          if (nk < K) {
            if (chmax(dp[i + 1][j + 1][nk], dp[i][j][k] + 1)) {
              pre[i + 1][j + 1][nk] = 3;
              pre2[i + 1][j + 1][nk] = k;
            }
          }
        }
      }
    }
  }
  int pk = -1, ans = -1;
  for (int i = 0; i < K; i++) {
    if (chmax(ans, dp[N][M][i])) pk = i;
  }
  if (ans == 0) {
    cout << "0\n";
    return 0;
  }
  string T;
  int pi = N, pj = M;
  while (pi > 0 || pj > 0) {
    int x = pre[pi][pj][pk];
    if (x == 1)
      pi--;
    else if (x == 2)
      pj--;
    else {
      pk = pre2[pi][pj][pk], pi--, pj--;
      T += A[pi];
    }
  }
  reverse(T.begin(), T.end());
  cout << T << '\n';
}