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 INF = (int)2e9 + 5;
string toUpperCase(string s) {
  string res = "";
  for (int i = 0; i < s.length(); i++) res += toupper(s[i]);
  return res;
}
string toLowerCase(string s) {
  string res = "";
  for (int i = 0; i < s.length(); i++) res += tolower(s[i]);
  return res;
}
int A[N][26];
int p[N];
string s1, s2;
string s;
int dp[N][N][N];
int calc(int i, int j, int k) {
  if (dp[i][j][k] != -1) return dp[i][j][k];
  if (i >= s1.length() || j >= s2.length()) return dp[i][j][k] = 0;
  dp[i][j][k] = 0;
  if (s1[i] == s2[j] && A[k][s1[i] - 'a'] < s.length() - 1)
    dp[i][j][k] = max(dp[i][j][k], 1 + calc(i + 1, j + 1, A[k][s1[i] - 'a']));
  dp[i][j][k] = max(dp[i][j][k], calc(i + 1, j, k));
  dp[i][j][k] = max(dp[i][j][k], calc(i, j + 1, k));
  return dp[i][j][k];
}
string ans;
void restore(int i, int j, int k) {
  if (i >= s1.length() || j >= s2.length()) return;
  if (k + 1 >= s.length()) return;
  if (s1[i] == s2[j] && A[k][s1[i] - 'a'] < s.length() - 1 &&
      calc(i, j, k) == 1 + calc(i + 1, j + 1, A[k][s1[i] - 'a'])) {
    ans += s1[i];
    restore(i + 1, j + 1, A[k][s1[i] - 'a']);
    return;
  }
  if (calc(i, j, k) == calc(i + 1, j, k)) {
    restore(i + 1, j, k);
    return;
  }
  if (calc(i, j, k) == calc(i, j + 1, k)) {
    restore(i, j + 1, k);
    return;
  }
}
int main() {
  cin >> s1 >> s2;
  s1 = toLowerCase(s1);
  s2 = toLowerCase(s2);
  cin >> s;
  s = toLowerCase(s);
  s += '#';
  p[0] = 0;
  for (int i = 1; i < s.length(); i++) {
    int j = p[i - 1];
    while (j > 0 && s[j] != s[i]) {
      j = p[j - 1];
    }
    if (s[i] == s[j]) j++;
    p[i] = j;
  }
  for (int j = 0; j < s.length(); j++) {
    for (int c = 0; c < 26; c++) {
      if (j > 0 && s[j] - 'a' != c) {
        A[j][c] = A[p[j - 1]][c];
      } else {
        A[j][c] = j + (s[j] - 'a' == c);
      }
    }
  }
  memset(dp, -1, sizeof dp);
  restore(0, 0, 0);
  if (ans == s.substr(0, s.length() - 1)) ans = "";
  if (ans.empty()) {
    cout << 0;
  } else
    cout << toUpperCase(ans);
}