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;
struct KMP {
  static const int MAXC = 26;
  int n;
  string s;
  vector<int> prefix;
  vector<vector<int>> nextState;
  KMP(string s) : s(s) {
    n = s.size();
    prefix.resize(n);
    nextState = vector<vector<int>>(n + 1, vector<int>(MAXC));
    calcPrefix();
    calcNextState();
  }
  void calcPrefix() {
    for (int i = 1; i < n; i++) {
      int k = prefix[i - 1];
      while (k && s[i] != s[k]) {
        k = prefix[k - 1];
      }
      if (s[i] == s[k]) {
        k++;
      }
      prefix[i] = k;
    }
  }
  void calcNextState() {
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j < MAXC; j++) {
        char x = j + 'A';
        if (i == n || (i && x != s[i])) {
          nextState[i][j] = nextState[prefix[i - 1]][j];
        } else {
          nextState[i][j] = i + (x == s[i]);
        }
      }
    }
  }
};
int d[105][105][105];
struct Trace {
  int i, j, k;
} trace[105][105][105];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  string s, t, virus;
  cin >> s >> t >> virus;
  KMP kmp(virus);
  int n = s.size(), m = t.size();
  auto relax = [&](int i, int j, int k) {
    if (d[i][j][k] < d[i][j + 1][k]) {
      d[i][j][k] = d[i][j + 1][k];
      trace[i][j][k] = {i, j + 1, k};
    }
    if (d[i][j][k] < d[i + 1][j][k]) {
      d[i][j][k] = d[i + 1][j][k];
      trace[i][j][k] = {i + 1, j, k};
    }
    int nxt = kmp.nextState[k][s[i] - 'A'];
    if (s[i] == t[j] && nxt < virus.size()) {
      if (d[i][j][k] < d[i + 1][j + 1][nxt] + 1) {
        d[i][j][k] = d[i + 1][j + 1][nxt] + 1;
        trace[i][j][k] = {i + 1, j + 1, nxt};
      }
    }
  };
  for (int i = n - 1; i >= 0; i--) {
    for (int j = m - 1; j >= 0; j--) {
      for (int k = 0; k < virus.size(); k++) {
        relax(i, j, k);
      }
    }
  }
  Trace state;
  int res = 0;
  for (int k = 0; k < virus.size(); k++) {
    if (res < d[0][0][k]) {
      res = d[0][0][k];
      state = {0, 0, k};
    }
  }
  if (!res)
    cout << 0;
  else {
    string ans;
    while (1) {
      auto newState = trace[state.i][state.j][state.k];
      if (newState.i > state.i && newState.j > state.j) {
        ans += s[state.i];
      }
      if (newState.i < state.i || newState.j < state.j) break;
      state = newState;
    }
    cout << ans;
  }
  return 0;
}