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 = 101;
const int mod = 1e9 + 7;
const int base = 67;
const int INF = 1e9 + 7;
string s1, s2, virus;
void Input() { cin >> s1 >> s2 >> virus; }
int memo[MAXN][MAXN][MAXN];
int f[MAXN];
int Pow[MAXN];
int calc(int id, char x) {
  if (virus[id] == x) return id + 1;
  int suff = (1LL * f[id - 1] * base % mod + x - 'A' + 1) % mod;
  for (int i = id - 1; i >= 1; i--) {
    int l = id - i + 1;
    int save =
        ((suff - 1LL * f[l - 1] * Pow[id - l + 1] % mod) % mod + mod) % mod;
    if (save == f[i]) return i + 1;
  }
  return 1;
}
int solve(int i, int j, int k) {
  if (k == (int)virus.size()) return -INF;
  if (i == (int)s1.size() || j == (int)s2.size()) return 0;
  if (memo[i][j][k] != -1) return memo[i][j][k];
  int cur = -INF;
  if (s1[i] == s2[j]) {
    int pos = calc(k, s1[i]);
    cur = max(cur, solve(i + 1, j + 1, pos) + 1);
  }
  cur = max(cur, solve(i + 1, j, k));
  cur = max(cur, solve(i, j + 1, k));
  return memo[i][j][k] = cur;
}
void Trace(int i, int j, int k) {
  if (i == (int)s1.size() || j == (int)s2.size()) return;
  if (solve(i, j, k) == solve(i + 1, j, k)) {
    Trace(i + 1, j, k);
    return;
  }
  if (solve(i, j, k) == solve(i, j + 1, k)) {
    Trace(i, j + 1, k);
    return;
  }
  if (s1[i] == s2[j]) {
    cout << s1[i];
    int pos = calc(k, s1[i]);
    if (s1[i] != virus[k])
      Trace(i + 1, j + 1, pos);
    else
      Trace(i + 1, j + 1, pos);
  }
}
void Init() {
  Pow[0] = 1;
  for (int i = 1; i <= 100; i++) Pow[i] = 1LL * Pow[i - 1] * base % mod;
  s1 = " " + s1;
  s2 = " " + s2;
  virus = " " + virus;
  for (int i = 1; i < (int)virus.size(); i++)
    f[i] = (1LL * f[i - 1] * base % mod + virus[i] - 'A' + 1) % mod;
  memset(memo, -1, sizeof memo);
}
void Output() {
  int ans = max(0, solve(1, 1, 1));
  if (ans == 0)
    cout << 0;
  else
    Trace(1, 1, 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  Input();
  Init();
  Output();
  return 0;
}