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 = 100010;
int dp[110][110][110];
tuple<int, int, int> tp[110][110][110];
vector<int> KMP(string &s) {
  int n = (int)s.length();
  vector<int> pi(n);
  for (int i = 1; i < n; ++i) {
    int 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;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s1, s2, virus;
  cin >> s1;
  cin >> s2;
  cin >> virus;
  int a = s1.length(), b = s2.length(), c = virus.length();
  vector<int> aux = KMP(virus);
  aux[0] = 0;
  for (int i = a; i >= 0; --i)
    for (int j = b; j >= 0; --j)
      for (int k = c; k >= 0; --k) {
        if (k == c) {
          dp[i][j][k] = INT_MIN;
          tp[i][j][k] = make_tuple(-1, -1, -1);
        } else if (i == a || j == b) {
          dp[i][j][k] = 0;
          tp[i][j][k] = make_tuple(-1, -1, -1);
        } else {
          if (dp[i + 1][j][k] > dp[i][j + 1][k]) {
            dp[i][j][k] = dp[i + 1][j][k];
            tp[i][j][k] = make_tuple(i + 1, j, k);
          } else {
            dp[i][j][k] = dp[i][j + 1][k];
            tp[i][j][k] = make_tuple(i, j + 1, k);
          }
          if (s1[i] == s2[j]) {
            int pos = k;
            char ch = s1[i];
            while (pos && virus[pos] != ch) pos = aux[pos - 1];
            if (virus[pos] == ch) ++pos;
            if (dp[i][j][k] < dp[i + 1][j + 1][pos] + 1) {
              dp[i][j][k] = dp[i + 1][j + 1][pos] + 1;
              tp[i][j][k] = make_tuple(i + 1, j + 1, pos);
            }
          }
        }
      }
  if (dp[0][0][0]) {
    tuple<int, int, int> t = make_tuple(0, 0, 0);
    while (get<0>(t) != -1) {
      if ((get<0>(tp[get<0>(t)][get<1>(t)][get<2>(t)]) == get<0>(t) + 1) &&
          (get<1>(tp[get<0>(t)][get<1>(t)][get<2>(t)]) == get<1>(t) + 1))
        cout << s1[get<0>(t)];
      t = tp[get<0>(t)][get<1>(t)][get<2>(t)];
    }
  } else
    cout << "0";
}