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 MAXN = 110;
string s, t, vir, ans;
int n, m, r, dp[MAXN][MAXN][MAXN], dist[MAXN][27];
void find_(int l, int r, int ind) {
  if (l == 0 || r == 0) return;
  if (dp[l - 1][r - 1][ind] == dp[l][r][ind]) {
    find_(l - 1, r - 1, ind);
    return;
  }
  if (dp[l][r - 1][ind] == dp[l][r][ind]) {
    find_(l, r - 1, ind);
    return;
  }
  if (dp[l - 1][r][ind] == dp[l][r][ind]) {
    find_(l - 1, r, ind);
    return;
  }
  ans = s[l - 1] + ans;
  for (int k = 0; k < r; k++) {
    if (((s[l - 1] == vir[k]) ? (k + 1) : dist[k][s[l - 1] - 'A']) == ind &&
        dp[l - 1][r - 1][k] + 1 == dp[l][r][ind]) {
      find_(l - 1, r - 1, k);
      return;
    }
  }
  return;
}
void prefix_f(int v, int u) {
  char me = char('A' + u);
  if (u == 26) me = vir[v];
  int local = dist[v - 1][26];
  while (local && vir[local] != me) local = dist[local - 1][26];
  if (vir[local] == me) local++;
  dist[v][u] = local;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> s >> t >> vir;
  n = s.size();
  m = t.size();
  r = vir.size();
  for (int i = 1; i <= r; i++)
    for (int j = 0; j < 27 - (i == r ? 1 : 0); j++) prefix_f(i, j);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = 0; k <= r; k++) {
        dp[i][j][k] = max(dp[i - 1][j][k], dp[i][j - 1][k]);
        dp[i][j][k] = max(dp[i - 1][j - 1][k], dp[i][j][k]);
      }
      if (s[i - 1] != t[j - 1]) continue;
      for (int k = 0; k < r; k++)
        dp[i][j][(s[i - 1] == vir[k]) ? (k + 1) : dist[k][s[i - 1] - 'A']] =
            max(dp[i][j]
                  [(s[i - 1] == vir[k]) ? (k + 1) : dist[k][s[i - 1] - 'A']],
                dp[i - 1][j - 1][k] + 1);
    }
  }
  int answer = -1e9;
  int ind = -1;
  for (int i = 0; i < r; i++) {
    if (answer < dp[n][m][i]) {
      ind = i;
      answer = dp[n][m][i];
    }
  }
  if (answer <= 0) return cout << 0 << endl, 0;
  find_(n, m, ind);
  cout << ans << endl;
  cin >> s;
  return 0;
}