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 long long MAXN = 100 + 10;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
long long poww(long long a, long long b, long long md) {
  return (!b ? 1
             : (b & 1 ? a * poww(a * a % md, b / 2, md) % md
                      : poww(a * a % md, b / 2, md) % md));
}
long long kmp[MAXN], pr[MAXN][26], dp[MAXN][MAXN][MAXN];
pair<long long, pair<long long, long long> > par[MAXN][MAXN][MAXN];
void parc(long long i, long long j, long long k, long long x, long long y,
          long long z, long long w) {
  if (dp[x][y][z] + w < dp[i][j][k]) return;
  dp[i][j][k] = dp[x][y][z] + w;
  par[i][j][k] = make_pair(x, make_pair(y, z));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  string s, t, v;
  cin >> s >> t >> v;
  long long n = s.size(), m = t.size(), k = v.size();
  for (int i = 1; i < k; i++) {
    int j = kmp[i - 1];
    while (j && v[i] != v[j]) j = kmp[j - 1];
    if (v[i] == v[j]) j++;
    kmp[i] = j;
  }
  for (int i = 0; i < k; i++)
    for (int j = 0; j < 26; j++)
      (i && v[i] - 'A' != j ? pr[i][j] = pr[kmp[i - 1]][j]
                            : pr[i][j] = i + (v[i] - 'A' == j));
  memset(dp, -1, sizeof dp);
  dp[0][0][0] = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      for (int l = 0; l < k; l++) {
        parc(i + 1, j, l, i, j, l, 0);
        parc(i, j + 1, l, i, j, l, 0);
        if (i < n && j < m && s[i] == t[j] && pr[l][s[i] - 'A'] < k)
          parc(i + 1, j + 1, pr[l][s[i] - 'A'], i, j, l, 1);
      }
    }
  }
  int a = n, b = m, c = 0;
  for (int i = 0; i < k; i++)
    if (dp[a][b][c] < dp[a][b][i]) c = i;
  string ans;
  while (a && b) {
    int i = par[a][b][c].first, j = par[a][b][c].second.first,
        l = par[a][b][c].second.second;
    if (dp[i][j][l] < dp[a][b][c]) ans += s[i];
    a = i;
    b = j;
    c = l;
  }
  reverse(ans.begin(), ans.end());
  if (!ans.size()) {
    cout << "0";
  } else {
    cout << ans;
  }
  return 0;
}