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;
string s1, s2, v;
int dp[102][102][102];
pair<pair<int, int>, int> nex[102][102][102];
int pi[102];
void do_pi() {
  int k = 0;
  pi[0] = pi[1] = 0;
  for (int i = 2; i <= v.size(); i++) {
    int j = pi[i - 1];
    while (1) {
      if (v[i - 1] == v[j]) {
        pi[i] = j + 1;
        break;
      }
      if (j == 0) {
        pi[i] = 0;
        break;
      }
      j = pi[j];
    }
  }
}
int fn(int a, int b, int c) {
  if (c == v.size()) return -(~(1 << 31)) / 100;
  if (a == s1.size() || b == s2.size()) {
    dp[a][b][c] = 0;
    return 0;
  }
  int &ret = dp[a][b][c];
  pair<pair<int, int>, int> &ne = nex[a][b][c];
  if (ret != -1) return ret;
  ret = 0;
  int fir = fn(a + 1, b, c);
  if (ret < fir) {
    ret = fir;
    ne = make_pair(make_pair(a + 1, b), c);
  }
  int sec = fn(a, b + 1, c);
  if (ret < sec) {
    ret = sec;
    ne = make_pair(make_pair(a, b + 1), c);
  }
  if (s1[a] == s2[b]) {
    if (s1[a] == v[c]) {
      fir = fn(a + 1, b + 1, c + 1) + 1;
      if (ret < fir) {
        ret = fir;
        ne = make_pair(make_pair(a + 1, b + 1), c + 1);
      }
    } else {
      int k = c;
      while (k != 0 && v[k] != s1[a]) {
        k = pi[k];
      }
      if (s1[a] == v[k]) k++;
      fir = fn(a + 1, b + 1, k) + 1;
      if (ret < fir) {
        ret = fir;
        ne = make_pair(make_pair(a + 1, b + 1), k);
      }
    }
  }
  return ret;
}
int main() {
  cin >> s1;
  cin >> s2;
  cin >> v;
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < 102; i++)
    for (int j = 0; j < 102; j++)
      for (int kk = 0; kk < 102; kk++)
        nex[i][j][kk] = make_pair(make_pair(-1, -1), -1);
  do_pi();
  int len = fn(0, 0, 0);
  if (len == 0) {
    cout << len << endl;
    return 0;
  }
  string ans;
  int a = 0;
  int b = 0;
  int c = 0;
  while (a != -1 && a != s1.size() && b != s2.size() && c != v.size()) {
    int na, nb, nc;
    pair<pair<int, int>, int> ne = nex[a][b][c];
    na = ne.first.first;
    nb = ne.first.second;
    nc = ne.second;
    if (min(min(na, nb), nc) == -1) break;
    if (dp[a][b][c] == dp[na][nb][nc] + 1) {
      ans.push_back(s1[a]);
    }
    a = na;
    b = nb;
    c = nc;
  }
  cout << ans << endl;
  return 0;
}