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 MAXN = 110;
string s1, s2;
string virus;
int b[MAXN];
int dp[MAXN][MAXN][MAXN];
int jdp[MAXN][256];
void pre(string &p) {
  int i = 0, j = -1;
  b[i] = j;
  while (i < p.size()) {
    while (j >= 0 and p[i] != p[j]) j = b[j];
    i++, j++;
    b[i] = j;
  }
}
int jump(int j, char s) {
  int &ans = jdp[j][s];
  if (ans != -1) return ans;
  while (j >= 0 and s != virus[j]) j = b[j];
  j++;
  if (j == virus.size()) j = -2;
  return ans = j;
}
int f(int i, int j, int code) {
  if (i == s1.size()) return 0;
  if (j == s2.size()) return 0;
  int &ans = dp[i][j][code];
  if (ans != -1) return ans;
  ans = f(i + 1, j, code);
  ans = max(f(i, j + 1, code), ans);
  if (s1[i] == s2[j]) {
    if (jump(code, s1[i]) != -2) {
      ans = max(ans, 1 + f(i + 1, j + 1, jump(code, s1[i])));
    }
  }
  return ans;
}
void rec(int i, int j, int code) {
  if (i == s1.size()) return;
  if (j == s2.size()) return;
  int a = f(i + 1, j, code);
  int b = f(i, j + 1, code);
  int c = 0;
  if (s1[i] == s2[j]) {
    if (jump(code, s1[i]) != -2) {
      c = 1 + f(i + 1, j + 1, jump(code, s1[i]));
    }
  }
  int x[] = {a, b, c};
  int maxi = max(a, max(b, c));
  if (a == maxi)
    rec(i + 1, j, code);
  else if (b == maxi)
    rec(i, j + 1, code);
  else {
    cout << s1[i];
    rec(i + 1, j + 1, jump(code, s1[i]));
  }
}
int main() {
  cin >> s1 >> s2 >> virus;
  pre(virus);
  memset(dp, (-1), sizeof dp);
  memset(jdp, (-1), sizeof jdp);
  for (int i = s1.size(); i >= 0; i--)
    for (int j = s2.size(); j >= 0; j--) f(i, j, 0);
  int ans = f(0, 0, 0);
  if (ans == 0)
    cout << 0 << endl;
  else {
    rec(0, 0, 0);
    cout << endl;
  }
  return 0;
}