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 = 310;
const int oo = 1e9;
string s1, s2;
string virus;
int aut[maxn][31];
int memo[maxn][maxn][maxn];
int id(const char &ch) { return ch - 'A'; }
int solve(int i, int j, int k) {
  if (k == (int)virus.size()) {
    return -oo;
  }
  if (i == (int)s1.size()) {
    return 0;
  }
  if (j == (int)s2.size()) {
    return 0;
  }
  int &on = memo[i][j][k];
  if (on == -1) {
    on = max(solve(i + 1, j, k), solve(i, j + 1, k));
    if (s1[i] == s2[j]) {
      on = max(on, solve(i + 1, j + 1, aut[k][id(s1[i])]) + 1);
    }
  }
  return on;
}
void pre(const string &s) {
  for (int i = 0; i < 26; i++) {
    aut[0][i] = 0;
  }
  int brd = 0;
  aut[0][id(s[0])] = 1;
  for (int i = 1; i <= (int)s.size(); i++) {
    for (int j = 0; j < 26; j++) {
      aut[i][j] = aut[brd][j];
    }
    if (i < (int)s.size()) {
      aut[i][id(s[i])] = i + 1;
      brd = aut[brd][id(s[i])];
    }
  }
}
vector<char> ans;
bool dfs(int i, int j, int k, int sz) {
  int &on = memo[i][j][k];
  if (sz + 1 == solve(0, 0, 0) && s1[i] == s2[j]) {
    if (!((s1[i] == virus[k]) && k + 1 == (int)virus.size())) {
      ans.push_back(s1[i]);
      return true;
    }
  }
  if (memo[i + 1][j][k] == memo[i][j][k]) {
    if (dfs(i + 1, j, k, sz)) {
      return true;
    }
  }
  if (memo[i][j + 1][k] == memo[i][j][k]) {
    if (dfs(i, j + 1, k, sz)) {
      return true;
    }
  }
  if (s1[i] == s2[j]) {
    if (memo[i + 1][j + 1][aut[k][id(s1[i])]] == memo[i][j][k] - 1) {
      if (dfs(i + 1, j + 1, aut[k][id(s1[i])], sz + 1)) {
        ans.push_back(s1[i]);
        return true;
      }
    }
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s1 >> s2 >> virus;
  pre(virus);
  memset(memo, -1, sizeof memo);
  if (solve(0, 0, 0)) {
    dfs(0, 0, 0, 0);
    reverse(ans.begin(), ans.end());
    for (auto &c : ans) {
      cout << c;
    }
    cout << '\n';
  } else {
    cout << 0 << '\n';
  }
  return 0;
}