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 MAX = 105, inf = 0x3f3f3f3f;
int f[MAX][MAX][MAX], KMP[MAX], tr[MAX][MAX][MAX];
pair<int, int> dp[MAX][MAX][MAX];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s1, s2, S;
  cin >> s1;
  cin >> s2;
  cin >> S;
  int n, m, l;
  n = s1.size();
  m = s2.size();
  l = S.size();
  s1 = ' ' + s1;
  s2 = ' ' + s2;
  S = ' ' + S;
  KMP[1] = 0;
  for (int i = 2, j = 0; i <= l; i++) {
    while (j > 0 && S[i] != S[j + 1]) j = KMP[j];
    if (S[j + 1] == S[i]) j++;
    KMP[i] = j;
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      f[i][j][0] = 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = 0; k < l; k++) {
        f[i][j][k] = max(f[i - 1][j][k], f[i][j - 1][k]);
        if (f[i][j][k] == f[i - 1][j][k]) {
          dp[i][j][k] = dp[i - 1][j][k];
          tr[i][j][k] = k;
        }
        if (f[i][j][k] == f[i][j - 1][k]) {
          dp[i][j][k] = dp[i][j - 1][k];
          tr[i][j][k] = k;
        }
      }
      if (s1[i] == s2[j]) {
        for (int k = 0; k < l; k++) {
          int u = k;
          while (u > 0 && s1[i] != S[u + 1]) u = KMP[u];
          if (S[u + 1] == s1[i]) u++;
          if (u != l) {
            if (f[i][j][u] < f[i - 1][j - 1][k] + 1) {
              f[i][j][u] = f[i - 1][j - 1][k] + 1;
              dp[i][j][u] = pair<int, int>(i, j);
              tr[i][j][u] = k;
            }
          }
        }
      }
    }
  }
  int res = 0, kr;
  for (int i = 0; i < l; i++) {
    if (f[n][m][i] > res) {
      res = f[n][m][i];
      kr = i;
    }
  }
  if (res == 0) {
    cout << 0;
    return 0;
  }
  string ans;
  int u = dp[n][m][kr].first, v = dp[n][m][kr].second;
  ans = s1[u];
  kr = tr[u][v][kr];
  u--;
  v--;
  while (--res) {
    pair<int, int> ne = dp[u][v][kr];
    u = ne.first;
    v = ne.second;
    kr = tr[u][v][kr];
    ans = s1[u] + ans;
    u--;
    v--;
  }
  cout << ans;
}