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 pi[102];
void kmpPreprocess(const string &P) {
  int i = 0, j = -1, m = P.size();
  pi[0] = -1;
  while (i < m) {
    while (j >= 0 and P[i] != P[j]) j = pi[j];
    i++, j++;
    pi[i] = j;
  }
}
string s1, s2, p;
int M[102][102][102];
int mov[102][102][102];
int DP(int a, int b, int j) {
  if (a == s1.size() or b == s2.size()) return 0;
  int &ans = M[a][b][j], &mv = mov[a][b][j], tmp;
  if (ans >= 0) return ans;
  ans = DP(a + 1, b, j);
  mv = -1;
  tmp = DP(a, b + 1, j);
  if (tmp > ans) {
    ans = tmp;
    mv = -2;
  }
  if (s1[a] == s2[b]) {
    char c = s1[a];
    while (j >= 0 and c != p[j]) j = pi[j];
    j++;
    if (j < p.size()) {
      tmp = 1 + DP(a + 1, b + 1, j);
      if (tmp > ans) {
        ans = tmp;
        mv = j;
      }
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> s1 >> s2 >> p;
  kmpPreprocess(p);
  memset(M, -1, sizeof M);
  int a = 0, b = 0, j = 0, i = 0, ans = DP(0, 0, 0), mv;
  if (ans) {
    while (i < ans) {
      mv = mov[a][b][j];
      if (mv == -1) {
        ++a;
      } else if (mv == -2) {
        ++b;
      } else {
        char c = s1[a];
        cout << c;
        j = mv;
        ++a;
        ++b;
        ++i;
      }
    }
  } else {
    cout << 0;
  }
  cout << endl;
}