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 MAX = 100 + 2, MOD = 100000007;
string s1, s2, s3;
int n1, n2, n3;
int L[MAX][27];
int dp[MAX][MAX][MAX];
bool vis[MAX][MAX][MAX];
int re(int i, int j, int k) {
  if (k >= n3) return -1e9;
  if (i >= n1 || j >= n2) return 0;
  int &ret = dp[i][j][k];
  if (vis[i][j][k]) return ret;
  ret = 0;
  vis[i][j][k] = true;
  if (s1[i] == s2[j]) {
    int temp;
    if (k - 1 >= 0)
      temp = L[k - 1][s1[i] - 'A'];
    else if (s1[i] == s3[0])
      temp = 1;
    else
      temp = 0;
    ret = max(ret, 1 + re(i + 1, j + 1, temp));
  }
  ret = max(ret, re(i + 1, j, k));
  ret = max(ret, re(i, j + 1, k));
  return ret;
}
void print(int i, int j, int k) {
  if (i >= n1 || j >= n2 || k >= n3) return;
  int ans = re(i, j, k);
  if (s1[i] == s2[j]) {
    int temp;
    if (k - 1 >= 0)
      temp = L[k - 1][s1[i] - 'A'];
    else if (s1[i] == s3[0])
      temp = 1;
    else
      temp = 0;
    if (1 + re(i + 1, j + 1, temp) == ans) {
      cout << s1[i];
      print(i + 1, j + 1, temp);
      return;
    }
  }
  if (re(i + 1, j, k) == ans)
    print(i + 1, j, k);
  else
    print(i, j + 1, k);
}
int f(string s) {
  int ret = 0;
  int n = (int)s.size();
  for (int i = n - 1; i > 0; i--) {
    int len = n - i;
    string e = s.substr(i, len);
    string st = s.substr(0, len);
    if (st == e) ret = len;
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> s1 >> s2 >> s3;
  n1 = s1.size();
  n2 = s2.size();
  n3 = s3.size();
  string t = "";
  for (int i = 0; i < n3; i++) {
    t += s3[i];
    for (char ch = 'A'; ch <= 'Z'; ch++) {
      if (i + 1 < n3 and ch == s3[i + 1]) {
        L[i][ch - 'A'] = i + 2;
        continue;
      }
      t += ch;
      L[i][ch - 'A'] = f(t);
      t.erase(i + 1, 1);
    }
  }
  memset(dp, -1, sizeof dp);
  if (re(0, 0, 0) == 0)
    cout << 0;
  else
    print(0, 0, 0);
  return 0;
}