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 N = 100 + 10;
char str1[N], str2[N], virus[N];
int n, m, k;
int F[N];
int dp[N][N][N];
void build() {
  F[0] = 0;
  int l = 0;
  for (int i = 1; i < k; ++i) {
    while (l && virus[l] != virus[i]) l = F[l - 1];
    if (virus[l] == virus[i]) ++l;
    F[i] = l;
  }
}
int calc(int i, int j, int p) {
  if (p == k) return -1e9;
  int &ret = dp[i][j][p];
  if (ret != -1) return ret;
  ret = 0;
  if (i == n || j == m) return 0;
  if (str1[i] == str2[j]) {
    int np = p;
    while (np && virus[np] != str1[i]) np = F[np - 1];
    if (str1[i] == virus[np]) ++np;
    ret = max(ret, 1 + calc(i + 1, j + 1, np));
  }
  return ret = max(ret, max(calc(i + 1, j, p), calc(i, j + 1, p)));
}
string res = "";
void calc(int i, int j, int p, int ans) {
  if (ans == 0) return;
  if (i == n || j == m) return;
  if (str1[i] == str2[j]) {
    int np = p;
    while (np && virus[np] != str1[i]) np = F[np - 1];
    if (str1[i] == virus[np]) ++np;
    if (np != k && dp[i + 1][j + 1][np] + 1 == ans) {
      res += str1[i];
      calc(i + 1, j + 1, np, ans - 1);
      return;
    }
  }
  if (dp[i + 1][j][p] == ans)
    calc(i + 1, j, p, ans);
  else
    calc(i, j + 1, p, ans);
}
int main(int argc, char *argv[]) {
  scanf("%s", str1);
  scanf("%s", str2);
  scanf("%s", virus);
  n = strlen(str1);
  m = strlen(str2);
  k = strlen(virus);
  memset(dp, -1, sizeof dp);
  build();
  int ans = calc(0, 0, 0);
  if (ans == 0) {
    puts("0");
    return 0;
  }
  calc(0, 0, 0, ans);
  printf("%s\n", res.c_str());
  return 0;
}