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;
int dp[101][101][101];
int ne[101][26];
string s1, s2, v;
int n1, n2, n3;
struct trip {
  int i, j, k;
  trip(int I = -1, int J = -1, int K = -1) {
    i = I;
    j = J;
    k = K;
  }
};
trip par[101][101][101];
int recu(int i, int j, int k) {
  if (i == n1 || j == n2) {
    return 0;
  }
  if (dp[i][j][k] == -1) {
    int ans = 0;
    if (recu(i + 1, j, k) > ans) {
      par[i][j][k] = {i + 1, j, k};
    }
    ans = max(ans, recu(i + 1, j, k));
    if (ans < recu(i, j + 1, k)) {
      par[i][j][k] = {i, j + 1, k};
    }
    ans = max(ans, recu(i, j + 1, k));
    if (s1[i] == s2[j]) {
      if (s1[i] == v[k] && k != n3 - 1) {
        if (ans < (1 + recu(i + 1, j + 1, k + 1))) {
          par[i][j][k] = trip(i + 1, j + 1, k + 1);
        }
        ans = max(ans, 1 + recu(i + 1, j + 1, k + 1));
      } else if (s1[i] != v[k]) {
        if (ans < (1 + recu(i + 1, j + 1, ne[k][s1[i] - 'A']))) {
          par[i][j][k] = trip(i + 1, j + 1, ne[k][s1[i] - 'A']);
        }
        ans = max(ans, 1 + recu(i + 1, j + 1, ne[k][s1[i] - 'A']));
      }
    }
    dp[i][j][k] = ans;
  }
  return dp[i][j][k];
}
void solve() {
  cin >> s1 >> s2 >> v;
  n1 = s1.length();
  n2 = s2.length();
  n3 = v.length();
  memset(dp, -1, sizeof(dp));
  string s;
  for (int i = 0; i < n3; i++) {
    if (i > 0) {
      s = v.substr(0, i + 1);
    }
    for (int j = 0; j < 26; j++) {
      if (i > 0) {
        s[i] = (j + 'A');
        ne[i][j] = 0;
        for (int len = s.length(); len > 0; len--) {
          if (s.substr(i + 1 - len) == v.substr(0, len)) {
            ne[i][j] = len;
            break;
          }
        }
      } else {
        ne[i][0] = 0;
      }
    }
  }
  int ans = recu(0, 0, 0);
  if (ans == 0)
    cout << 0 << endl;
  else {
    string s;
    int i = 0;
    int j = 0;
    int k = 0;
    while (i < n1 && j < n2 && i != -1 && j != -1 && k != -1) {
      if (par[i][j][k].i == i + 1 && par[i][j][k].j == j + 1) {
        s += s1[i];
        auto temp = par[i][j][k];
        i = temp.i;
        j = temp.j;
        k = temp.k;
      } else {
        auto temp = par[i][j][k];
        i = temp.i;
        j = temp.j;
        k = temp.k;
      }
    }
    cout << s << endl;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}