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;
string a, b, v, ans;
const int N = 105;
int dp[N][N][N];
pair<int, pair<int, int> > nxt[N][N][N];
int f[N];
int PF(int len, char c) {
  while (len && v[len] != c) len = f[len - 1];
  if (v[len] == c) len++;
  return len;
}
void computeF() {
  f[0] = 0;
  int len = 0;
  if (v.size()) {
    for (int i = 1; i < v.size(); i++) {
      len = PF(len, v[i]);
      f[i] = len;
    }
  }
}
int solve(int i = 0, int j = 0, int k = 0) {
  if (k == v.size()) return -N - N;
  if (i == a.size() || j == b.size()) return 0;
  int &ret = dp[i][j][k];
  if (ret != -1) return ret;
  ret = -N;
  if (ret < solve(i + 1, j, k)) {
    ret = solve(i + 1, j, k);
    nxt[i][j][k] = {i + 1, {j, k}};
  }
  if (ret < solve(i, j + 1, k)) {
    ret = solve(i, j + 1, k);
    nxt[i][j][k] = {i, {j + 1, k}};
  }
  if (a[i] == b[j]) {
    int x = PF(k, a[i]);
    if (ret < solve(i + 1, j + 1, x) + 1) {
      ret = solve(i + 1, j + 1, x) + 1;
      nxt[i][j][k] = {i + 1, {j + 1, x}};
    }
  }
  return ret;
}
void construct(int i = 0, int j = 0, int k = 0) {
  if (i == a.size() || j == b.size()) return;
  if (nxt[i][j][k].first == i + 1 && nxt[i][j][k].second.first == j + 1)
    ans += a[i];
  construct(nxt[i][j][k].first, nxt[i][j][k].second.first,
            nxt[i][j][k].second.second);
}
int main() {
  cin >> a >> b >> v;
  computeF();
  memset(dp, -1, sizeof dp);
  if (!solve())
    puts("0");
  else {
    construct();
    cout << ans << endl;
  }
  return 0;
}