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 ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ll N = 1e2 + 5;
string s1, s2, virus, final, glo_tmp;
int n, m, l, dp[N][N][N];
pair<int, pair<int, int>> where[N][N][N];
ll base = 1e9 + 7;
ull pw2[N];
void init_base() {
  pw2[0] = 1;
  for (int i = 1; i < N; i++) {
    pw2[i] = pw2[i - 1] * base;
  }
}
struct SingleHash {
  vector<ull> pre2;
  SingleHash() {}
  SingleHash(const string& s) { make(s); }
  void make(string s = "") {
    int n = s.size();
    pre2 = vector<ull>(n + 5u, 0);
    for (int i = 1; i <= n; i++) {
      pre2[i] = pre2[i - 1] + s[i] * pw2[i - 1];
    }
  }
  inline ull operator()(const int pos, const int len) const {
    int l = pos;
    int r = pos + len - 1;
    ull h2 = pre2[r] - pre2[l - 1];
    h2 *= pw2[N - r];
    return h2;
  }
} hash1;
int solve(int i, int j, int k) {
  if (k >= l) return -1e9;
  if (i >= n or j >= m) return 0;
  if (dp[i][j][k] != -1) return dp[i][j][k];
  int ans = -1e9;
  if (s1[i] == s2[j]) {
    bool f = false;
    if (s1[i] == virus[k]) f = true;
    int nk = 0;
    if (!f or f) {
      string tmp = "";
      tmp += '#';
      for (int r = 0; r < k; r++) tmp += virus[r];
      tmp += s1[i];
      tmp += '#';
      SingleHash hash2(tmp);
      for (int r = 1; r <= k + 1; r++) {
        if (hash1(1, r) == hash2(k + 1 - r + 1, r)) {
          nk = r;
        }
      }
    }
    int x = solve(i + 1, j + 1, (nk)) + 1;
    if (x > ans) {
      ans = x;
      where[i][j][k] = {i + 1, {j + 1, (nk)}};
    }
  }
  int y = solve(i + 1, j, k);
  if (y > ans) {
    ans = y;
    where[i][j][k] = {i + 1, {j, k}};
  }
  int z = solve(i, j + 1, k);
  if (z > ans) {
    ans = z;
    where[i][j][k] = {i, {j + 1, k}};
  }
  return dp[i][j][k] = ans;
}
void back_track(int i, int j, int k) {
  if (k >= l) return;
  if (i >= n or j >= m) return;
  pair<int, pair<int, int>> p = make_pair(0, make_pair(0, 0));
  if (where[i][j][k] == p) return;
  p = where[i][j][k];
  if (p.first == i + 1 and p.second.first == j + 1) final += s1[i];
  back_track(p.first, p.second.first, p.second.second);
}
void code() {
  cin >> s1 >> s2 >> virus;
  n = s1.size(), m = s2.size(), l = virus.size();
  init_base();
  glo_tmp = '#' + virus + '#';
  hash1.make(glo_tmp);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        where[i][j][k] = make_pair(0, make_pair(0, 0));
      }
    }
  }
  memset(dp, -1, sizeof(dp));
  int ans = solve(0, 0, 0);
  if (ans == 0) {
    cout << ans << "\n";
  } else {
    back_track(0, 0, 0);
    cout << final << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t = 1;
  while (t-- > 0) {
    code();
  }
}