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;
int dadsadasda;
const int INF = 0x3f3f3f3f;
const long long LLINF = 1e18;
const int MAXN = 110;
const int ALPHA = 26;
string S1, S2, V;
int PI[MAXN];
void pf() {
  int n = (int)V.size();
  for (int i = 1; i < n; i++) {
    int j = PI[i - 1];
    while (j > 0 && V[j] != V[i]) j = PI[j - 1];
    if (V[i] == V[j]) PI[i] = j + 1;
  }
}
int NXT[MAXN][ALPHA];
void pre() {
  int n = (int)V.size();
  V += '$';
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < ALPHA; j++) {
      int k = i;
      while (k > 0 && V[k] != ('A' + j)) k = PI[k - 1];
      if (V[k] == ('A' + j)) NXT[i][j] = k + 1;
    }
  }
  V.pop_back();
}
int DP[MAXN][MAXN][MAXN];
bool VIS[MAXN][MAXN][MAXN];
int f(int p1, int p2, int pi) {
  if (pi == (int)V.size()) return DP[p1][p2][pi] = -INF;
  if (p1 == (int)S1.size() || p2 == (int)S2.size()) return 0;
  int &ret = DP[p1][p2][pi];
  if (VIS[p1][p2][pi]) return ret;
  VIS[p1][p2][pi] = true;
  ret = max(f(p1 + 1, p2, pi), f(p1, p2 + 1, pi));
  if (S1[p1] == S2[p2])
    ret = max(ret, 1 + f(p1 + 1, p2 + 1, NXT[pi][S1[p1] - 'A']));
  return ret;
}
int main() {
  cin >> S1 >> S2 >> V;
  pf();
  pre();
  int ans = f(0, 0, 0);
  if (ans == 0)
    printf("0");
  else {
    int p1 = 0, p2 = 0, pi = 0;
    while (DP[p1][p2][pi] > 0) {
      if (DP[p1][p2][pi] == DP[p1 + 1][p2][pi])
        ++p1;
      else if (DP[p1][p2][pi] == DP[p1][p2 + 1][pi])
        ++p2;
      else {
        printf("%c", S1[p1]);
        pi = NXT[pi][S1[p1] - 'A'];
        ++p1, ++p2;
      }
    }
  }
  printf("\n");
  return 0;
}