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 in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
const long long maxn = 1e2 + 10;
long long dp[maxn][maxn][maxn];
long long kmp[maxn];
struct st {
  long long a, b, c;
  st(long long i, long long j, long long k) { a = i, b = j, c = k; }
  st() { a = b = c = -1; }
};
st pre[maxn][maxn][maxn];
inline void build_kmp(string &s) {
  long long tmp = 0;
  for (long long i = 1; i < s.size(); i++) {
    while (tmp && s[tmp] != s[i]) tmp = kmp[tmp - 1];
    if (s[tmp] == s[i]) tmp++;
    kmp[i] = tmp;
  }
}
st START;
inline void relax(long long i, long long j, long long match, long long preI,
                  long long preJ, long long preMatch, long long fl = 0) {
  if (dp[preI][preJ][preMatch] + fl > dp[i][j][match]) {
    dp[i][j][match] = dp[preI][preJ][preMatch] + fl;
    pre[i][j][match] = {preI, preJ, preMatch};
  }
}
string s, t, virus;
inline void printSol(st cur) {
  if (cur.a <= 0) return;
  printSol(pre[cur.a][cur.b][cur.c]);
  if (cur.a >= 1) {
    st pre = ::pre[cur.a][cur.b][cur.c];
    if (dp[cur.a][cur.b][cur.c] ==
        (pre.a >= 1 ? dp[pre.a][pre.b][pre.c] : 0) + 1)
      cout << s[cur.a];
  }
}
int32_t main() {
  cin >> s >> t >> virus;
  s = "@" + s;
  t = "@" + t;
  build_kmp(virus);
  long long n = s.size();
  long long m = t.size();
  long long res = 0;
  for (long long i = 1; i < n; i++) {
    for (long long j = 1; j < m; j++) {
      for (long long match = 0; match < virus.size(); match++) {
        relax(i, j, match, i - 1, j, match);
        relax(i, j, match, i, j - 1, match);
        if (s[i] == t[j]) {
          long long tmp = match;
          while (tmp && virus[tmp] != s[i]) tmp = kmp[tmp - 1];
          if (s[i] == virus[tmp]) tmp++;
          relax(i, j, tmp, i - 1, j - 1, match, 1);
        }
      }
    }
  }
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < m; j++)
      for (long long k = 0; k < virus.size(); k++)
        if (res < dp[i][j][k]) res = dp[i][j][k], START = {i, j, k};
  if (res == 0) cout << 0 << endl;
  printSol(START);
}