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;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int oo = -1000000;
string x, xx, xxx;
int memo[105][102][102];
int b[105];
pair<int, pair<long long, long long> > dp[105][102][102];
bool solved[105][102][102];
int solve(int i, int j, int k) {
  int kkk;
  bool ok = false;
  if (k == xxx.length()) return oo;
  if (i == x.length() || j == xx.length() || k == xxx.length()) {
    return 0;
  }
  if (solved[i][j][k]) return memo[i][j][k];
  solved[i][j][k] = 1;
  int op1 = 0, op2 = 0, op3 = 0;
  pair<int, pair<long long, long long> > o1, o2, o3;
  if (x[i] == xx[j]) {
    if (i == 1 && j == 1 && k == 1) {
      int ttt = 0;
    }
    ok = true;
    o1 = pair<int, pair<long long, long long> >(
        i + 1, pair<long long, long long>(j + 1, k + 1));
    if (xx[j] == xxx[k])
      op1 = solve(i + 1, j + 1, k + 1) + 1,
      o1 = pair<int, pair<long long, long long> >(
          i + 1, pair<long long, long long>(j + 1, k + 1));
    else {
      int kk = k;
      while (kk >= 0 && xxx[kk] != xx[j]) kk = b[kk];
      kk++;
      o1 = pair<int, pair<long long, long long> >(
          i + 1, pair<long long, long long>(j + 1, kk));
      op1 = solve(i + 1, j + 1, kk) + 1;
    }
  }
  op2 = solve(i, j + 1, k);
  o2 = pair<int, pair<long long, long long> >(
      i, pair<long long, long long>(j + 1, k));
  op3 = solve(i + 1, j, k);
  o3 = pair<int, pair<long long, long long> >(i + 1,
                                              pair<long long, long long>(j, k));
  int ans = max(op1, max(op2, op3));
  if (ans == op1 && ok) {
    dp[i][j][k] = o1;
  } else if (ans == op2) {
    dp[i][j][k] = o2;
  } else
    dp[i][j][k] = o3;
  return memo[i][j][k] = ans;
}
int main() {
  while (cin >> x >> xx >> xxx) {
    memset(b, 0, sizeof(b));
    int i = 0, j = -1;
    b[0] = -1;
    int m = xxx.length();
    while (i < m) {
      while (j >= 0 && xxx[i] != xxx[j]) j = b[j];
      i++, j++;
      b[i] = j;
    }
    memset(memo, 0, sizeof memo);
    memset(solved, 0, sizeof solved);
    solve(0, 0, 0);
    int n = x.length();
    int nn = xx.length();
    int tt = 0, jj = 0, kk = 0;
    long long mx = 0;
    mx = memo[0][0][0];
    string ans = "";
    while (mx) {
      pair<int, pair<long long, long long> > p = dp[tt][jj][kk];
      int u = p.first, v = p.second.first, vv = p.second.second;
      if (memo[u][v][vv] < memo[tt][jj][kk] && x[tt] == xx[jj])
        ans += x[tt], mx--;
      tt = u, jj = v, kk = vv;
    }
    if (ans.size() == 0) {
      cout << 0 << endl;
      continue;
    }
    cout << ans << endl;
  }
}