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;
map<char, vector<int>> mp;
string s1, s2, pat;
int cache[105][105][105];
string ap[105][105][105];
void dfa(string s, vector<char> c) {
  string p;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < c.size(); j++) {
      p += c[j];
      int kk = min((int)s.size(), i + 1);
      do {
        int f = 0;
        int hei = 0;
        for (int k = i - kk + 1; k <= i; k++) {
          if (p[k] != s[hei]) {
            f = 1;
            break;
          } else
            hei++;
        }
        if (!f) break;
        kk--;
      } while (kk);
      mp[c[j]][i] = kk;
      p.pop_back();
    }
    if (i < s.size()) p += s[i];
  }
}
int dp(int i, int j, int st) {
  if (i == s1.size() || j == s2.size()) return 0;
  if (cache[i][j][st] != -1) return cache[i][j][st];
  int &ans = cache[i][j][st];
  if (s1[i] == s2[j]) {
    ans = dp(i + 1, j + 1, st);
    ap[i][j][st] = ap[i + 1][j + 1][st];
    int q = st;
    st = mp[s1[i]][st];
    if (pat.size() != st) {
      if (ans < dp(i + 1, j + 1, st) + 1) {
        ans = dp(i + 1, j + 1, st) + 1;
        ap[i][j][q] = s1[i] + ap[i + 1][j + 1][st];
      }
    }
  } else {
    ans = dp(i + 1, j, st);
    ap[i][j][st] = ap[i + 1][j][st];
    if (ans < dp(i, j + 1, st)) {
      ans = dp(i, j + 1, st);
      ap[i][j][st] = ap[i][j + 1][st];
    }
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s1 >> s2 >> pat;
  vector<int> v(pat.size() + 1);
  for (char j = 'A'; j <= 'Z'; j++) mp[j] = v;
  memset(cache, -1, sizeof(cache));
  vector<char> c;
  for (auto i : pat) c.push_back(i);
  dfa(pat, c);
  dp(0, 0, 0);
  if (ap[0][0][0].size())
    cout << ap[0][0][0];
  else
    cout << 0;
}