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 = 105;
int pi[maxn][30], p[maxn];
int dp[maxn][maxn][maxn], go[maxn][maxn][maxn];
int to[maxn][maxn][maxn];
int main() {
  string c, d, e;
  string a = " ", b = " ", virus = " ";
  cin >> c >> d >> e;
  a += c, b += d, virus += e;
  for (int i = 0; i <= 'z' - 'a'; ++i) pi[0][i] = 0;
  pi[0][virus[1] - 'A'] = 1;
  int q = 0;
  p[1] = 0;
  for (int i = 2; i < (int)virus.size(); ++i) {
    while (q && virus[q + 1] != virus[i]) q = p[q];
    if (virus[q + 1] == virus[i]) ++q;
    p[i] = q;
  }
  for (int i = 1; i < (int)virus.size() - 1; ++i) {
    pi[i][virus[i + 1] - 'A'] = i + 1;
    for (int j = 0; j <= 'Z' - 'A'; ++j) {
      if (j == (virus[i + 1] - 'A')) continue;
      int t = i;
      for (; t && virus[t + 1] - 'A' != j;) t = p[t];
      pi[i][j] = pi[t][j];
    }
  }
  int vl = virus.size();
  int n = a.size(), m = b.size();
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      for (int k = 0; k < vl - 1; ++k) dp[i][j][k] = -1e6;
  dp[0][0][0] = 0;
  for (int i = 0; i < max(n, m); ++i) dp[i][0][0] = dp[0][i][0] = 0;
  for (int i = 1; i < n; ++i)
    for (int j = 1; j < m; ++j) {
      if (a[i] == b[j]) {
        for (int k = 0; k < vl - 1; ++k)
          if (dp[i - 1][j - 1][k] + 1 > dp[i][j][pi[k][a[i] - 'A']]) {
            dp[i][j][pi[k][a[i] - 'A']] = dp[i - 1][j - 1][k] + 1;
            go[i][j][pi[k][a[i] - 'A']] = 3;
            to[i][j][pi[k][a[i] - 'A']] = k;
          }
      }
      for (int k = 0; k < vl - 1; ++k) {
        if (dp[i - 1][j][k] > dp[i][j][k]) {
          dp[i][j][k] = dp[i - 1][j][k];
          go[i][j][k] = 1;
        }
        if (dp[i][j - 1][k] > dp[i][j][k]) {
          dp[i][j][k] = dp[i][j - 1][k];
          go[i][j][k] = 2;
        }
        if (dp[i - 1][j - 1][k] > dp[i][j][k]) {
          dp[i][j][k] = dp[i - 1][j - 1][k];
          go[i][j][k] = 4;
        }
      }
    }
  int ans = 0, ind = 0;
  for (int k = 0; k < vl - 1; ++k)
    if (dp[n - 1][m - 1][k] > ans) {
      ans = dp[n - 1][m - 1][k];
      ind = k;
    }
  if (ans == 0) {
    cout << ans << "\n";
    return 0;
  }
  int l = n - 1, r = m - 1, now_k = ind;
  string sans;
  do {
    if (go[l][r][now_k] == 3) {
      now_k = to[l][r][now_k];
      l--;
      r--;
      sans += a[l + 1];
    } else if (go[l][r][now_k] == 2)
      r--;
    else if (go[l][r][now_k] == 1)
      l--;
    else if (go[l][r][now_k] == 4) {
      l--;
      r--;
    }
  } while (l != 0 && r != 0);
  for (int i = (int)sans.size() - 1; i >= 0; --i) cout << sans[i];
  return 0;
}