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 N = 200;
const long long mod = 1e9 + 7;
long long z[3 * N];
long long dp[N][N][N];
string pr[N][N][N];
long long f(string a, long long m) {
  long long n = int32_t(a.size()), l = 0, r = 0;
  for (long long i = 0; i <= n; i++) {
    z[i] = 0;
  }
  long long ma = 0;
  for (long long i = 1; i < n; i++) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (a[z[i]] == a[z[i] + i]) {
      z[i]++;
    }
    if (i + z[i] - 1 > r) {
      r = i + z[i] - 1;
      l = i;
    }
    if (i > m) ma = max(ma, z[i]);
  }
  return ma;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string a, b, c;
  cin >> a >> b >> c;
  a = " " + a;
  b = " " + b;
  long long n = int32_t(a.size());
  long long m = int32_t(b.size());
  long long d = int32_t(c.size());
  string kc = c;
  c = " " + c;
  for (long long i = 1; i < n; i++) {
    for (long long j = 1; j < m; j++) {
      for (long long k = 0; k < d; k++) {
        if (a[i] != b[j] &&
            max(dp[i][j - 1][k], dp[i - 1][j][k]) > dp[i][j][k]) {
          if (dp[i][j - 1][k] > dp[i - 1][j][k]) {
            pr[i][j][k] = pr[i][j - 1][k];
            dp[i][j][k] = dp[i][j - 1][k];
          } else {
            pr[i][j][k] = pr[i - 1][j][k];
            dp[i][j][k] = dp[i - 1][j][k];
          }
          continue;
        }
        if (a[i] != b[j]) continue;
        string t = kc + "#" + pr[i - 1][j - 1][k] + a[i];
        long long per = f(t, int32_t(kc.size()));
        if (dp[i][j][per] < dp[i - 1][j - 1][k] + 1) {
          dp[i][j][per] = dp[i - 1][j - 1][k] + 1;
          pr[i][j][per] = pr[i - 1][j - 1][k] + a[i];
        }
        if (dp[i][j][k] < dp[i - 1][j - 1][k]) {
          dp[i][j][k] = dp[i - 1][j - 1][k];
          pr[i][j][k] = pr[i - 1][j - 1][k];
        }
      }
    }
  }
  long long ma = 0;
  string ans = "";
  for (long long j = 0; j < d; j++) {
    if (dp[n - 1][m - 1][j] > ma) {
      ma = dp[n - 1][m - 1][j];
      ans = pr[n - 1][m - 1][j];
    }
  }
  if (ma == 0)
    cout << ma;
  else
    cout << ans;
}