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[102][102][102];
int lps[102];
string s1, s2, virus;
string ans = "";
void countLps() {
  int i = 1, len = 0;
  lps[0] = 0;
  int N = virus.size();
  while (i < N) {
    if (virus[i] == virus[len]) {
      lps[i++] = ++len;
    } else {
      if (len != 0)
        len = lps[len - 1];
      else
        lps[i++] = 0;
    }
  }
}
int solve(int i, int j, int k) {
  if (k == virus.size()) return -1e9;
  if (i == s1.size()) return 0;
  if (j == s2.size()) return 0;
  int& ret = dp[i][j][k];
  if (ret != -1) return ret;
  ret = max(solve(i + 1, j, k), solve(i, j + 1, k));
  if (s1[i] == s2[j] && s1[i] == virus[k])
    ret = max(solve(i + 1, j + 1, k + 1) + 1, ret);
  if (s1[i] == s2[j] && s1[i] != virus[k]) {
    int where = k;
    while (where > 0 && virus[where] != s1[i]) where = lps[where - 1];
    if (virus[where] == s1[i])
      ret = max(solve(i + 1, j + 1, where + 1) + 1, ret);
    else
      ret = max(solve(i + 1, j + 1, where) + 1, ret);
  }
  return ret;
}
void path(int i, int j, int k) {
  if (k == virus.size()) return;
  if (i == s1.size()) return;
  if (j == s2.size()) return;
  int sol1 = solve(i + 1, j, k);
  int sol2 = solve(i, j + 1, k);
  int sol3 = -1;
  int sol4 = -1;
  int sol5 = -1;
  int real = solve(i, j, k);
  int where = k;
  while (where > 0 && virus[where] != s1[i]) where = lps[where - 1];
  if (s1[i] == s2[j] && s1[i] == virus[k])
    sol3 = solve(i + 1, j + 1, k + 1) + 1;
  if (s1[i] == s2[j] && s1[i] != virus[k]) {
    if (virus[where] == s1[i])
      sol4 = solve(i + 1, j + 1, where + 1) + 1;
    else
      sol5 = solve(i + 1, j + 1, where) + 1;
  }
  if (real == sol1) {
    path(i + 1, j, k);
  } else if (real == sol2) {
    path(i, j + 1, k);
  } else if (real == sol3) {
    ans += s1[i];
    path(i + 1, j + 1, k + 1);
  } else {
    ans += s1[i];
    if (virus[where] == s1[i])
      path(i + 1, j + 1, where + 1);
    else
      path(i + 1, j + 1, where);
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  cin >> s1 >> s2 >> virus;
  countLps();
  memset(dp, -1, sizeof dp);
  if (solve(0, 0, 0) == 0) {
    cout << 0;
  } else {
    path(0, 0, 0);
    cout << ans;
  }
  return 0;
}