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;
using ll = long long;
using pii = pair<int, int>;
using tpl = tuple<int, int, int>;
using pcc = pair<char, char>;
const ll inf = 1e18 + 100;
const ll mod = 1e9 + 7;
int dr[] = {-1, 0, 1, 0};
int dc[] = {0, 1, 0, -1};
int kr[] = {-1, 1, -2, -2, -1, 1, 2, 2};
int kc[] = {-2, -2, -1, 1, 2, 2, -1, 1};
int dgr[] = {-1, -1, 1, 1};
int dgc[] = {1, -1, -1, 1};
const int N = 150;
string A, B, V;
int dp[N][N][N], len1, len2, len3;
int fail[N];
int fun(int i, int j, int k) {
  if (i == len1 or j == len2 or k == len3) {
    if (k != len3) return 0;
    return -1111;
  }
  int &mami = dp[i][j][k];
  if (mami != -1) return mami;
  int ans = -1111;
  ans = max(fun(i + 1, j, k), fun(i, j + 1, k));
  if (A[i] == B[j]) {
    int temp = k;
    while (temp >= 1) {
      if (A[i] == V[temp]) {
        break;
      } else {
        temp = fail[temp];
      }
    }
    if (A[i] == V[temp])
      temp++;
    else
      temp = 0;
    ans = max(ans, 1 + fun(i + 1, j + 1, temp));
  }
  return mami = ans;
}
void sol(int i, int j, int k) {
  if (i == len1 or j == len2 or k == len3) return;
  int ans1 = fun(i + 1, j, k);
  int ans3 = fun(i, j + 1, k);
  int ans2 = -1111;
  int temp = k;
  if (A[i] == B[j]) {
    while (temp >= 1) {
      if (A[i] == V[temp]) {
        break;
      } else {
        temp = fail[temp];
      }
    }
    if (A[i] == V[temp])
      temp++;
    else
      temp = 0;
    ans2 = 1 + fun(i + 1, j + 1, temp);
  }
  if (ans2 > ans1 && ans2 > ans3) {
    printf("%c", A[i]);
    sol(i + 1, j + 1, temp);
  } else {
    if (ans1 > ans3)
      sol(i + 1, j, k);
    else
      sol(i, j + 1, k);
  }
  return;
}
void pref_fun() {
  fail[0] = -1;
  fail[1] = 0;
  for (int i = 2; i <= len3; i++) {
    int j = fail[i - 1];
    while (j >= 0 && V[i - 1] != V[j]) j = fail[j];
    fail[i] = ++j;
  }
}
void solve() {
  cin >> A >> B >> V;
  len1 = A.size(), len2 = B.size(), len3 = V.size();
  memset(dp, -1, sizeof dp);
  pref_fun();
  int ans = fun(0, 0, 0);
  if (ans > 0)
    sol(0, 0, 0);
  else
    printf("0\n");
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}