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 mod = 1e9 + 7;
const int N = 1e2 + 5;
const int inf = 0x3f3f3f3f;
string s1, s2, v, f[N][N][N], ans;
int pi[N], len1, len2, lenv;
inline void update(string& a, string b) { a = (a.size() > b.size() ? a : b); }
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s1 >> s2 >> v;
  len1 = s1.length();
  len2 = s2.length();
  lenv = v.length();
  for (int i = 1, j = 0; i < lenv; i++) {
    while (j > 0 && v[i] != v[j]) j = pi[j - 1];
    if (v[i] == v[j]) pi[i] = ++j;
  }
  for (int i = 1; i <= len1; i++)
    for (int j = 1; j <= len2; j++)
      for (int k = 0; k < lenv; k++) {
        if (s1[i - 1] == s2[j - 1]) {
          char tmp = s1[i - 1];
          int t = k;
          while (t > 0 && tmp != v[t]) t = pi[t - 1];
          if (tmp == v[t]) t++;
          update(f[i][j][t], f[i - 1][j - 1][k] + tmp);
        }
        update(f[i][j][k], f[i - 1][j][k]);
        update(f[i][j][k], f[i][j - 1][k]);
      }
  for (int i = 0; i < lenv; i++) update(ans, f[len1][len2][i]);
  if (ans.size() == 0)
    return puts("0"), 0;
  else
    cout << ans << endl;
  return 0;
}