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;
string a, b, virus;
int dyn[101][101][101];
int choice[101][101][101];
int moves[101][256];
int rec(int n, int m, int v) {
  if (n < 0 || m < 0) return 0;
  if (dyn[n][m][v] >= 0) return dyn[n][m][v];
  if (a[n] == b[m]) {
    choice[n][m][v] = ((rec(n - 1, m, v) > rec(n, m - 1, v)) ? 1 : 0);
    dyn[n][m][v] = max(rec(n - 1, m, v), rec(n, m - 1, v));
    for (int l = max(v - 1, 0); l < virus.size(); l++) {
      if (moves[l][a[n]] == v) {
        int res = rec(n - 1, m - 1, l) + 1;
        if (res > dyn[n][m][v]) {
          dyn[n][m][v] = res;
          choice[n][m][v] = 2 + l;
        }
      }
    }
    return dyn[n][m][v];
  }
  choice[n][m][v] = ((rec(n - 1, m, v) > rec(n, m - 1, v)) ? 1 : 0);
  return dyn[n][m][v] = max(rec(n - 1, m, v), rec(n, m - 1, v));
}
int main() {
  memset(dyn, -1, sizeof(dyn));
  cin >> a >> b >> virus;
  memset(moves, 0, sizeof(moves));
  moves[0][virus[0]] = 1;
  for (int i = 0; i < virus.size(); i++) {
    for (int j = 'A'; j <= 'Z'; j++) {
      if (virus[i] == j)
        moves[i][j] = i + 1;
      else {
        bool f = false;
        if (i == 4 && j == 'A') f = true;
        for (int q = i - 1; q >= 0; q--) {
          bool fail = false;
          for (int z = i - q; z < i; z++) {
            if (virus[z] != virus[z - (i - q)]) {
              fail = true;
              break;
            }
          }
          if (!fail) {
            if (virus[q] == j) {
              moves[i][j] = q + 1;
              break;
            }
          }
        }
      }
    }
  }
  string ttt = "AB";
  int best = 0, besti;
  for (int i = 0; i < virus.size(); i++) {
    if (rec(a.size() - 1, b.size() - 1, i) > best) {
      best = rec(a.size() - 1, b.size() - 1, i);
      besti = i;
    }
  }
  vector<char> ans;
  int n = a.size() - 1;
  int m = b.size() - 1;
  int v = besti;
  while (ans.size() < best) {
    int c = choice[n][m][v];
    if (c == 0)
      m--;
    else if (c == 1)
      n--;
    else {
      ans.push_back(a[n]);
      n--;
      m--;
      v = c - 2;
    }
  }
  if (best == 0) {
    cout << "0\n";
    return 0;
  }
  for (int i = best - 1; i >= 0; i--) cout << ans[i];
  cout << "\n";
}