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 MOD = 1000000007;
int dp[111][111][111];
string a, b, v;
int prfx[111], n, m, l;
int solve(int p1, int p2, int pv) {
  int& r = dp[p1][p2][pv];
  if (r != -1) return r;
  if (pv > l) return r = -2;
  if (p1 == n || p2 == m) return r = 0;
  r = solve(p1 + 1, p2, pv);
  r = max(r, solve(p1, p2 + 1, pv));
  if (a[p1] == b[p2]) {
    while (pv >= 0 && v[pv] != a[p1]) pv = prfx[pv];
    pv += 1;
    if (pv < l) r = max(r, 1 + solve(p1 + 1, p2 + 1, pv));
  }
  return r;
}
void printAns(int p1, int p2, int pv, string& fans) {
  if (p1 == n || p2 == m) {
    cout << fans << "\n";
    return;
  }
  int r = dp[p1][p2][pv];
  if (dp[p1 + 1][p2][pv] == r) return printAns(p1 + 1, p2, pv, fans);
  if (dp[p1][p2 + 1][pv] == r) return printAns(p1, p2 + 1, pv, fans);
  while (pv >= 0 && v[pv] != a[p1]) pv = prfx[pv];
  fans += a[p1];
  printAns(p1 + 1, p2 + 1, pv + 1, fans);
}
int main() {
  cin >> a >> b >> v;
  n = a.length();
  m = b.length();
  l = v.length();
  prfx[0] = -1;
  prfx[1] = 0;
  for (int i = 2, j = 0; i <= l; ++i) {
    if (v[i - 1] == v[j])
      prfx[i] = ++j;
    else if (j > 0)
      j = prfx[j], i -= 1;
    else
      prfx[i] = j = 0;
  }
  for (int i = 0; i < (n + 1); ++i)
    for (int j = 0; j < (m + 1); ++j)
      for (int k = 0; k < (l + 1); ++k) dp[i][j][k] = -1;
  int ans = solve(0, 0, 0);
  if (ans > 0) {
    string str = "";
    printAns(0, 0, 0, str);
  } else
    cout << ans << endl;
  return 0;
}