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;
long long int power(long long int a, long long int b) {
  if (b == 0) return 1;
  if (b & 1) return a * power(a, b - 1);
  long long int temp = power(a, b / 2);
  return temp * temp;
}
bool mycompare(long long int a, long long int b) { return a > b; }
int reset[101];
string s1, s2, lucky;
int l1, l2, l3;
int dp[101][101][101];
void buildtable() {
  reset[0] = -1;
  int i = 0, j = -1;
  while (i < l3) {
    while (j >= 0 && lucky[i] != lucky[j]) j = reset[j];
    j++;
    i++;
    reset[i] = j;
  }
  return;
}
int kmp(int j, char c) {
  while (j >= 0 && lucky[j] != c) j = reset[j];
  j++;
  return j;
}
int helper(int i, int j, int k) {
  ;
  if (k == l3) return INT_MIN + 1;
  if (i == l1 || j == l2) return 0;
  if (dp[i][j][k] != -1) return dp[i][j][k];
  int ans = 0;
  if (s1[i] == s2[j]) {
    int temp = kmp(k, s1[i]);
    ans = max(ans, 1 + helper(i + 1, j + 1, temp));
  }
  int op1 = helper(i + 1, j, k);
  int op2 = helper(i, j + 1, k);
  return dp[i][j][k] = max(ans, max(op1, op2));
}
bool flag = false;
void construct(int i, int j, int k) {
  if (i == l1 || j == l2) return;
  int ans = helper(i, j, k);
  if (ans == helper(i + 1, j, k)) {
    construct(i + 1, j, k);
    return;
  }
  if (ans == helper(i, j + 1, k)) {
    construct(i, j + 1, k);
    return;
  }
  cout << s1[i];
  flag = true;
  construct(i + 1, j + 1, kmp(k, s1[i]));
  return;
}
void solve() {
  cin >> s1 >> s2 >> lucky;
  l1 = s1.size();
  ;
  l2 = s2.size();
  ;
  l3 = lucky.size();
  ;
  buildtable();
  memset(dp, -1, sizeof dp);
  int ans = helper(0, 0, 0);
  if (!ans)
    cout << '0';
  else
    construct(0, 0, 0);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int test = 1;
  while (test--) {
    solve();
  }
}