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;
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
const int MAXN = 102;
int F[MAXN];
void kmpPreprocess(const string& P) {
  int m = (int)P.size();
  int i = 0, j = -1;
  F[0] = -1;
  while (i < m) {
    while (j >= 0 && P[i] != P[j]) j = F[j];
    i++;
    j++;
    F[i] = j;
  }
}
string s1, s2, virus;
int n, m, w;
long long pd[MAXN][MAXN][MAXN];
pair<int, pair<int, int> > getr[MAXN][MAXN][MAXN];
long long solve(int x, int y, int v) {
  if (v == w) return -10000;
  if (x == n || y == m) return 0;
  if (pd[x][y][v] == -1) {
    long long ans = -10000;
    if (s1[x] == s2[y]) {
      int k = v;
      while (k > 0 && virus[k] != s1[x]) {
        k = F[k];
      }
      if (virus[k] == s1[x]) k++;
      if (solve(x + 1, y + 1, k) > ans)
        getr[x][y][v] =
            pair<int, pair<int, int> >(x + 1, pair<int, int>(y + 1, k));
      ans = max(ans, solve(x + 1, y + 1, k));
      if (ans >= 0) ans++;
    }
    if (solve(x + 1, y, v) > ans)
      getr[x][y][v] = pair<int, pair<int, int> >(x + 1, pair<int, int>(y, v));
    ans = max(ans, solve(x + 1, y, v));
    if (solve(x, y + 1, v) > ans)
      getr[x][y][v] = pair<int, pair<int, int> >(x, pair<int, int>(y + 1, v));
    ans = max(ans, solve(x, y + 1, v));
    pd[x][y][v] = ans;
  }
  return pd[x][y][v];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  while (cin >> s1 >> s2 >> virus) {
    n = (int)s1.size(), m = (int)s2.size(), w = (int)virus.size();
    kmpPreprocess(virus);
    memset(pd, -1, sizeof pd);
    int aux = solve(0, 0, 0);
    string final = "";
    if (aux > 0) {
      int a = 0, b = 0, c = 0;
      while (a < n && b < m) {
        if (getr[a][b][c].first > a && getr[a][b][c].second.first > b) {
          final += s1[a];
        }
        int na = getr[a][b][c].first;
        int nb = getr[a][b][c].second.first;
        int nc = getr[a][b][c].second.second;
        a = na, b = nb, c = nc;
      }
      cout << final << endl;
    } else {
      cout << "0" << endl;
    }
  }
}