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, a;
char ch[110];
int cnt = 0;
vector<char> V1, V2;
int dp[102][102][102];
int pi[102];
int failureFunction(string pat) {
  int i, shift = 0, len = pat.size();
  for (i = 2; i < len; ++i) {
    while (shift > 0 && pat[shift] != pat[i - 1]) shift = pi[shift];
    if (pat[shift] == pat[i - 1]) shift++;
    pi[i] = shift;
  }
  return i - 1;
}
int solve(int i, int j, int k) {
  if (i == s1.size() || j == s2.size()) return 0;
  if (dp[i][j][k] != -1) return dp[i][j][k];
  int ret = 0;
  if (s1[i] == s2[j]) {
    if (k + 1 == v.size() && s1[i] == v[k])
      ;
    else {
      int shift = k;
      while (shift > 0 && v[shift] != s1[i]) shift = pi[shift];
      ret =
          max(ret,
              solve(i + 1, j + 1, (s1[i] == v[shift]) ? shift + 1 : shift) + 1);
    }
  }
  ret = max(ret, solve(i + 1, j, k));
  ret = max(ret, solve(i, j + 1, k));
  return dp[i][j][k] = ret;
}
void print(int i, int j, int k) {
  if (i == s1.size() || j == s2.size()) return;
  int ret1 = 0, ret2 = 0, ret3 = 0;
  if (s1[i] == s2[j]) {
    if (k + 1 == v.size() && s1[i] == v[k])
      ;
    else {
      int shift = k;
      while (shift > 0 && v[shift] != s1[i]) shift = pi[shift];
      ret1 = solve(i + 1, j + 1, (s1[i] == v[shift]) ? shift + 1 : shift) + 1;
    }
  }
  ret2 = solve(i + 1, j, k);
  ret3 = solve(i, j + 1, k);
  if (ret1 > ret2 && ret1 > ret3) {
    if (k + 1 == v.size() && s1[i] == v[k])
      ;
    else {
      cout << s1[i];
      int shift = k;
      while (shift > 0 && v[shift] != s1[i]) shift = pi[shift];
      print(i + 1, j + 1, (s1[i] == v[shift]) ? shift + 1 : shift);
      return;
    }
  }
  if (ret2 > ret3) {
    print(i + 1, j, k);
    return;
  }
  print(i, j + 1, k);
}
int main() {
  cin >> s1 >> s2 >> v;
  failureFunction(v);
  memset(dp, -1, sizeof dp);
  if (solve(0, 0, 0))
    print(0, 0, 0);
  else
    printf("0");
}