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 modx(long long Base, long long exponent) {
  long long ans = 1;
  if (Base == 1) return Base;
  while (exponent) {
    if (exponent & 1) ans = (ans * Base) % 1000000007LL;
    Base = (Base * Base) % 1000000007LL;
    exponent = exponent >> 1;
  }
  return ans;
}
long long inmodx(long long num) { return (modx(num, 1000000007LL - 2LL)); }
bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  if (a.first.first / 900 < b.first.first / 900) return 1;
  if (a.first.first / 900 > b.first.first / 900) return 0;
  if (a.first.second <= b.first.second) return 1;
  return 0;
}
const int N = (1e2) + 9;
const int M = (N << 2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 450;
int dp[N][N][N];
pair<pair<int, int>, int> par[N][N][N];
string a, b, c, res;
int PRE[N];
void build_PRE(string pattern) {
  int i, n = pattern.length(), k;
  k = -2;
  for (i = (0); i < (n); i++) {
    while (k >= -1 && pattern[k + 1] != pattern[i])
      k = (k == -1) ? (-2) : (PRE[k]);
    PRE[i] = ++k;
  }
  return;
}
void solve() {
  int na, nb, nc, i, j, k, len, x, y, z, ans;
  cin >> a >> b >> c;
  na = a.length();
  nb = b.length();
  nc = c.length();
  build_PRE(c);
  for (i = (0); i < (na + 1); i++)
    for (j = (0); j < (nb + 1); j++)
      for (k = (0); k < (nc + 1); k++) dp[i][j][k] = -1000000011;
  dp[0][0][0] = 0;
  for (i = (0); i < (na + 1); i++)
    for (j = (0); j < (nb + 1); j++)
      for (k = (0); k < (nc); k++)
        if (dp[i][j][k] >= 0) {
          if (dp[i][j][k] > dp[i + 1][j][k]) {
            dp[i + 1][j][k] = dp[i][j][k];
            par[i + 1][j][k] = {{i, j}, k};
          }
          if (dp[i][j][k] > dp[i][j + 1][k]) {
            dp[i][j + 1][k] = dp[i][j][k];
            par[i][j + 1][k] = {{i, j}, k};
          }
          if (i == na || j == nb) continue;
          if (a[i] == b[j]) {
            if (c[k] == a[i]) {
              if (dp[i][j][k] + 1 > dp[i + 1][j + 1][k + 1]) {
                dp[i + 1][j + 1][k + 1] = dp[i][j][k] + 1;
                par[i + 1][j + 1][k + 1] = {{i, j}, k};
              }
            } else if (k == 0) {
              if (dp[i][j][k] + 1 > dp[i + 1][j + 1][k]) {
                dp[i + 1][j + 1][k] = dp[i][j][k] + 1;
                par[i + 1][j + 1][k] = {{i, j}, k};
              }
            } else {
              len = PRE[k - 1];
              while (len >= -1 && c[len + 1] != a[i])
                len = (len == -1) ? (-2) : (PRE[len]);
              ++len;
              if (dp[i][j][k] + 1 > dp[i + 1][j + 1][len + 1]) {
                dp[i + 1][j + 1][len + 1] = dp[i][j][k] + 1;
                par[i + 1][j + 1][len + 1] = {{i, j}, k};
              }
            }
          }
        }
  ans = -1000000011;
  x = na;
  y = nb;
  z = -1;
  for (k = (0); k < (nc); k++)
    if (ans < dp[x][y][k]) {
      ans = dp[x][y][k];
      z = k;
    }
  if (ans == 0) {
    cout << 0 << '\n';
    return;
  }
  res = "";
  while (x > 0 && y > 0) {
    i = par[x][y][z].first.first;
    j = par[x][y][z].first.second;
    k = par[x][y][z].second;
    if (dp[i][j][k] < dp[x][y][z]) res += a[i];
    x = i;
    y = j;
    z = k;
  }
  reverse((res).begin(), (res).end());
  cout << res << '\n';
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1, cs;
  cout << fixed << setprecision(6);
  for (cs = (1); cs < (t + 1); cs++) {
    solve();
  }
  return 0;
}