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;
template <class T>
T _abs(T n) {
  return (n < 0 ? -n : n);
}
template <class T>
T _max(T a, T b) {
  return (!(a < b) ? a : b);
}
template <class T>
T _min(T a, T b) {
  return (a < b ? a : b);
}
template <class T>
T sq(T x) {
  return x * x;
}
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
int dp[110][110][110], cn[110][26];
bool vis[110][110][110];
char s1[110], s2[110], vir[110];
int dfs(int p, int q, int r) {
  if (!vir[r]) return -10000;
  if (!s1[p] || !s2[q]) return 0;
  if (vis[p][q][r]) return dp[p][q][r];
  vis[p][q][r] = 1;
  int a = 0;
  if (s1[p] == s2[q]) {
    a = max(a, dfs(p + 1, q + 1, cn[r][s1[p] - 'A']) + 1);
  }
  a = max(a, dfs(p + 1, q, r));
  a = max(a, dfs(p, q + 1, r));
  return dp[p][q][r] = a;
}
string dfs2(int p, int q, int r) {
  if (!s1[p] || !s2[q]) return "";
  if (s1[p] == s2[q]) {
    if (dp[p][q][r] == (dfs(p + 1, q + 1, cn[r][s1[p] - 'A']) + 1)) {
      string second = dfs2(p + 1, q + 1, cn[r][s1[p] - 'A']);
      return string("") + (s1[p]) + second;
    }
  }
  if (dp[p][q][r] == dfs(p + 1, q, r)) return dfs2(p + 1, q, r);
  if (dp[p][q][r] == dfs(p, q + 1, r)) return dfs2(p, q + 1, r);
  assert(0);
}
int main() {
  cin >> s1 >> s2 >> vir;
  int i, j, k;
  for (i = 0; vir[i]; i++) {
    for (j = i; j >= 0; j--)
      if (!cn[i][vir[j] - 'A']) {
        for (k = 1; k <= j && vir[j - k] == vir[i - k]; k++)
          ;
        if (k == j + 1) cn[i][vir[j] - 'A'] = j + 1;
      }
  }
  if (dfs(0, 0, 0))
    cout << dfs2(0, 0, 0) << '\n';
  else
    cout << 0 << '\n';
  return 0;
}