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;
int N, M;
string s1, s2, v;
int memo[108][108][108];
int N_s1, N_s2, N_v;
vector<int> P;
void Cal() {
  memset(memo, -1, sizeof memo);
  P.push_back(0);
  for (int i = 1, k = 0; v[i]; i++) {
    while (k && v[i] != v[k]) k = P[k - 1];
    if (v[i] == v[k]) k++;
    P.push_back(k);
  }
}
int res(int index_s1, int index_s2, int index_v) {
  if (index_v >= N_v) return -123;
  if (index_s1 >= N_s1 || index_s2 >= N_s2) return 0;
  if (memo[index_s1][index_s2][index_v] != -1)
    return memo[index_s1][index_s2][index_v];
  int &ret = memo[index_s1][index_s2][index_v];
  int X = 0;
  if (s1[index_s1] == s2[index_s2]) {
    int k = index_v;
    while (k && s1[index_s1] != v[k]) k = P[k - 1];
    if (s1[index_s1] == v[k]) k++;
    if (v[k]) X = 1 + res(index_s1 + 1, index_s2 + 1, k);
  }
  return ret = max(0, max(X, max(res(index_s1 + 1, index_s2, index_v),
                                 res(index_s1, index_s2 + 1, index_v))));
}
string mm = "";
void solve(int index_s1, int index_s2, int index_v) {
  if (index_s1 >= N_s1 || index_s2 >= N_s2) return;
  int to = memo[index_s1][index_s2][index_v];
  if (s1[index_s1] == s2[index_s2]) {
    int k = index_v;
    while (k && s1[index_s1] != v[k]) k = P[k - 1];
    if (s1[index_s1] == v[k]) k++;
    if (to == 1 + res(index_s1 + 1, index_s2 + 1, k)) {
      mm += s1[index_s1];
      solve(index_s1 + 1, index_s2 + 1, k);
      return;
    }
  }
  if (to == res(index_s1 + 1, index_s2, index_v))
    solve(index_s1 + 1, index_s2, index_v);
  else
    solve(index_s1, index_s2 + 1, index_v);
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s1 >> s2 >> v;
  Cal();
  N_s1 = s1.size(), N_s2 = s2.size(), N_v = v.size();
  if (!res(0, 0, 0)) {
    cout << 0;
    return 0;
  }
  solve(0, 0, 0);
  cout << mm;
}