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;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
const long long mod = 1e9 + 7;
const int maxn = 110;
const int inf = 1e9;
string s, t, v;
int n, m, l;
int dp[maxn][maxn][maxn];
pair<pair<int, int>, int> nxt[maxn][maxn][maxn];
map<pair<char, int>, int> mp;
int get(char c, int k) {
  if (mp.count({c, k})) return mp[{c, k}];
  string cur_suffix = v.substr(0, k) + c;
  int len = cur_suffix.length();
  for (int j = l; j >= 0; j--) {
    string buf = v.substr(0, j);
    if (cur_suffix.find(buf) == string::npos) {
      continue;
    }
    int idx = cur_suffix.rfind(buf);
    if (idx + j == len) {
      return mp[{c, k}] = j;
    }
  }
  return mp[{c, k}] = 0;
}
void relax(int i, int j, int k, int x, int y, int z, int dx) {
  if (dp[x][y][z] + dx > dp[i][j][k]) {
    dp[i][j][k] = dx + dp[x][y][z];
    nxt[i][j][k] = {{x, y}, z};
  }
}
int go(int i, int j, int k) {
  if (k == l) return dp[i][j][k] = -inf;
  if (i == n || j == m) return dp[i][j][k] = 0;
  if (~dp[i][j][k]) return dp[i][j][k];
  dp[i][j][k] = 0;
  go(i + 1, j, k);
  relax(i, j, k, i + 1, j, k, 0);
  go(i, j + 1, k);
  relax(i, j, k, i, j + 1, k, 0);
  if (s[i] == t[j]) {
    if (s[i] == v[k]) {
      go(i + 1, j + 1, k + 1);
      relax(i, j, k, i + 1, j + 1, k + 1, 1);
    } else {
      int f = get(s[i], k);
      go(i + 1, j + 1, f);
      relax(i, j, k, i + 1, j + 1, f, 1);
    }
  }
  return dp[i][j][k];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s >> t >> v;
  n = s.length();
  m = t.length();
  l = v.length();
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      for (int k = 0; k <= l; k++) {
        nxt[i][j][k] = make_pair(make_pair(-1, -1), -1);
      }
    }
  }
  memset(dp, -1, sizeof(dp));
  go(0, 0, 0);
  int len = dp[0][0][0];
  if (len == 0) out(len);
  pair<pair<int, int>, int> at = {{0, 0}, 0};
  string ans;
  while (1) {
    int i = at.first.first;
    int j = at.first.second;
    int k = at.second;
    auto to = nxt[i][j][k];
    if (to == make_pair(make_pair(-1, -1), -1)) break;
    int x = to.first.first;
    int y = to.first.second;
    int z = to.second;
    if (dp[i][j][k] == 1 + dp[x][y][z]) {
      ans += s[i];
    }
    at = to;
  }
  cout << ans << endl;
  return 0;
}