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 N = 105;
const int L = 26;
string s, t, pattern;
int lps[N], f[N][L], dp[N][N][N];
inline void precompute() {
  for (int i = 1; i < pattern.size(); i++) {
    int j = lps[i - 1];
    while (j > 0 and pattern[j] != pattern[i]) {
      j = lps[j - 1];
    }
    j += pattern[i] == pattern[j];
    lps[i] = j;
  }
  for (int j = 0; j < 26; j++) {
    f[0][j] = (pattern[0] - 'A') == j ? 1 : 0;
  }
  for (int i = 1; i < pattern.size(); i++) {
    for (int j = 0; j < 26; j++) {
      f[i][j] = (pattern[i] - 'A') == j ? i + 1 : f[lps[i - 1]][j];
    }
  }
  for (int j = 0; j < 26; j++) {
    f[pattern.size()][j] = f[lps[(int)pattern.size() - 1]][j];
  }
}
inline int solve(int i, int j, int match) {
  if (match == pattern.size()) return -(N * N);
  if (i == s.size() || j == t.size()) return 0;
  if (dp[i][j][match] != -1) return dp[i][j][match];
  int res = max(solve(i + 1, j, match), solve(i, j + 1, match));
  if (s[i] == t[j]) {
    res = max(res, 1 + solve(i + 1, j + 1, f[match][s[i] - 'A']));
  }
  return dp[i][j][match] = res;
}
int main() {
  cin >> s >> t >> pattern;
  precompute();
  memset(dp, -1, sizeof dp);
  int lcs = solve(0, 0, 0);
  if (!lcs) {
    cout << lcs << '\n';
    return 0;
  }
  int i = 0, j = 0, k = 0;
  while (lcs) {
    int x = dp[i + 1][j][k];
    int y = dp[i][j + 1][k];
    int z = (s[i] == t[j]) ? (1 + dp[i + 1][j + 1][f[k][s[i] - 'A']]) : (0);
    if (x == dp[i][j][k]) {
      i++;
    } else if (y == dp[i][j][k]) {
      j++;
    } else {
      cout << s[i];
      k = f[k][s[i] - 'A'];
      lcs--, i++, j++;
    }
  }
}