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 Inf = 1 << 30;
const int maxn = 100 + 10;
int dp[maxn][maxn][maxn];
int par[maxn][maxn][maxn];
string s1, s2, v;
inline bool Ok(string ff, int t) {
  for (int i = t; i > 0; --i)
    if (ff[t - i] != v[v.size() - i]) return false;
  return true;
}
inline int Find(int t, char now) {
  string me;
  me += now;
  for (int i = t; i > 0; --i) me += v[v.size() - i];
  for (int i = t; i >= 1; --i)
    if (Ok(me, i)) return i;
  return 0;
}
int f[maxn][30];
inline int Solve(int fi, int se, int th) {
  if (fi < 0 || se < 0) return 0;
  int &ret = dp[fi][se][th];
  if (ret > -1) return ret;
  ret = 0;
  ret = Solve(fi - 1, se, th);
  par[fi][se][th] = 2;
  int q = Solve(fi, se - 1, th);
  if (q > ret) ret = q, par[fi][se][th] = 3;
  if (s1[fi] == s2[se]) {
    q = 0;
    int z = th;
    if (s1[fi] == v[v.size() - 1 - th])
      z++;
    else
      z = f[z][s1[fi] - 'A'];
    if (z < v.size()) q = Solve(fi - 1, se - 1, z) + 1;
    if (q > ret) ret = q, par[fi][se][th] = 1;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  memset(dp, -1, sizeof dp);
  memset(par, -1, sizeof par);
  cin >> s1 >> s2 >> v;
  for (int i = 0; i < v.size(); ++i)
    for (int j = 0; j < 26; ++j) {
      f[i][j] = Find(i, j + 'A');
    }
  if (Solve(s1.size() - 1, s2.size() - 1, 0) == 0)
    cout << 0 << endl;
  else {
    string ret = "";
    int fi = s1.size() - 1, se = s2.size() - 1, th = 0;
    while (fi >= 0 && se >= 0) {
      int nx = par[fi][se][th];
      if (nx == 1) {
        fi--, se--;
        ret += s1[fi + 1];
        if (v[v.size() - th - 1] == s1[fi + 1])
          th++;
        else
          th = f[th][s1[fi + 1] - 'A'];
      } else if (nx == 2)
        fi--;
      else if (nx == 3)
        se--;
      else
        break;
    }
    reverse(ret.begin(), ret.end());
    cout << ret << endl;
  }
  return 0;
}