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>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int maxN = 110;
struct state {
  int a, b, c;
  int sym;
  state() { a = b = c = 0; }
  state(int a, int b, int c, int sym) : a(a), b(b), c(c), sym(sym) {}
};
string s, t, u;
char cs[maxN], ct[maxN], cu[maxN];
int dp[maxN][maxN][maxN];
state from[maxN][maxN][maxN];
int mov[maxN][3 * maxN];
int main() {
  cin >> s >> t >> u;
  int n = s.length(), m = t.length(), lim = u.length();
  for (int i = 0; i < n; ++i) {
    cs[i + 1] = s[i];
  }
  for (int i = 0; i < m; ++i) {
    ct[i + 1] = t[i];
  }
  for (int i = 0; i < lim; ++i) {
    cu[i + 1] = u[i];
  }
  for (int i = 0; i < lim; ++i) {
    for (int c = 'A'; c <= 'Z'; ++c) {
      string val = "";
      for (int j = 0; j < i; ++j) {
        val += u[j];
      }
      val += (char)(c);
      mov[i][c] = 0;
      for (int k = 0; k < val.size(); ++k) {
        int clen = (int)(val.size()) - k;
        int good = true;
        for (int cl = k; cl < val.size(); ++cl) {
          if (val[cl] != u[cl - k]) {
            good = false;
          }
        }
        if (good) {
          mov[i][c] = clen;
          break;
        }
      }
    }
  }
  memset(dp, -1, sizeof(dp));
  dp[0][0][0] = 0;
  from[0][0][0] = state(-1, -1, -1, -1);
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) {
      for (int k = 0; k < lim; ++k) {
        if (dp[i][j][k] != -1) {
          if (i + 1 <= n && j + 1 <= m) {
            if (cs[i + 1] == ct[j + 1]) {
              int add = 0;
              if (cs[i + 1] == cu[k + 1]) {
                ++add;
              }
              int nk = k + add;
              if (add == 0) nk = mov[k][cs[i + 1]];
              if (nk < lim) {
                if (dp[i + 1][j + 1][nk] < dp[i][j][k] + 1) {
                  dp[i + 1][j + 1][nk] = dp[i][j][k] + 1;
                  from[i + 1][j + 1][nk] = state(i, j, k, (int)(cs[i + 1]));
                }
              }
            }
          }
          if (i + 1 <= n) {
            if (dp[i + 1][j][k] < dp[i][j][k]) {
              dp[i + 1][j][k] = dp[i][j][k];
              from[i + 1][j][k] = state(i, j, k, -1);
            }
          }
          if (j + 1 <= m) {
            if (dp[i][j + 1][k] < dp[i][j][k]) {
              dp[i][j + 1][k] = dp[i][j][k];
              from[i][j + 1][k] = state(i, j, k, -1);
            }
          }
        }
      }
    }
  }
  int mx = -1;
  int index = -1;
  for (int i = 0; i < lim; ++i) {
    if (dp[n][m][i] > mx) {
      mx = dp[n][m][i];
      index = i;
    }
  }
  if (mx <= 0) {
    cout << 0 << endl;
    return 0;
  }
  int i = n, j = m, k = index;
  string res = "";
  while (true) {
    state t = from[i][j][k];
    if (t.sym != -1) {
      res += (char)(t.sym);
    }
    i = t.a, j = t.b, k = t.c;
    if (i < 0) {
      break;
    }
  }
  reverse(res.begin(), res.end());
  cout << res << endl;
  return 0;
}