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 = 1e6 + 5, K = 20, mod = 1000000007, MOD = 1000000007,
                INF = LLONG_MAX / 2;
vector<long long> prefix_function(string s) {
  long long n = (long long)s.length();
  vector<long long> pi(n);
  for (long long i = 1; i < n; i++) {
    long long j = pi[i - 1];
    while (j > 0 && s[i] != s[j]) j = pi[j - 1];
    if (s[i] == s[j]) j++;
    pi[i] = j;
  }
  return pi;
}
void compute_automaton(string s, vector<vector<long long>>& aut) {
  s += '#';
  long long n = s.size();
  vector<long long> pi = prefix_function(s);
  aut.assign(n, vector<long long>(26));
  for (long long i = 0; i < n; i++) {
    for (long long c = 0; c < 26; c++) {
      if (i > 0 && 'A' + c != s[i])
        aut[i][c] = aut[pi[i - 1]][c];
      else
        aut[i][c] = i + ('A' + c == s[i]);
    }
  }
}
long long dp[105][105][105], rel[105][105][105][3];
void solve() {
  string s, t, v;
  cin >> s >> t >> v;
  long long n = s.size(), m = t.size(), z = v.size();
  vector<vector<long long>> aut(z + 1, vector<long long>(29, 0));
  compute_automaton(v, aut);
  string ans;
  long long mx = 0;
  memset(rel, -1, sizeof rel);
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      for (long long k = 0; k < z; k++) {
        if (s[i] == t[j] && aut[k][s[i] - 'A'] < z) {
          if (dp[i + 1][j + 1][aut[k][s[i] - 'A']] < dp[i][j][k] + 1) {
            dp[i + 1][j + 1][aut[k][s[i] - 'A']] = dp[i][j][k] + 1;
            rel[i + 1][j + 1][aut[k][s[i] - 'A']][0] = i;
            rel[i + 1][j + 1][aut[k][s[i] - 'A']][1] = j;
            rel[i + 1][j + 1][aut[k][s[i] - 'A']][2] = k;
          }
        }
        if (dp[i][j][k] > dp[i + 1][j][k]) {
          dp[i + 1][j][k] = dp[i][j][k];
          rel[i + 1][j][k][0] = rel[i][j][k][0];
          rel[i + 1][j][k][1] = rel[i][j][k][1];
          rel[i + 1][j][k][2] = rel[i][j][k][2];
        }
        if (dp[i][j][k] > dp[i][j + 1][k]) {
          dp[i][j + 1][k] = dp[i][j][k];
          rel[i][j + 1][k][0] = rel[i][j][k][0];
          rel[i][j + 1][k][1] = rel[i][j][k][1];
          rel[i][j + 1][k][2] = rel[i][j][k][2];
        }
      }
    }
  }
  long long a, b, c;
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j <= m; j++) {
      for (long long k = 0; k < z; k++) {
        if (mx < dp[i][j][k]) {
          mx = dp[i][j][k];
          a = rel[i][j][k][0];
          b = rel[i][j][k][1];
          c = rel[i][j][k][2];
        }
      }
    }
  }
  if (!mx) {
    cout << 0 << endl;
    return;
  }
  while (a > -1 && b > -1) {
    ans = s[a] + ans;
    long long i = rel[a][b][c][0];
    long long j = rel[a][b][c][1];
    long long k = rel[a][b][c][2];
    a = i;
    b = j;
    c = k;
  }
  cout << ans << endl;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long TESTS = 1;
  while (TESTS--) {
    solve();
  }
  return 0;
}