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 maxn = 100 + 10;
char s1[maxn], s2[maxn], v[maxn];
int l1, l2, lv;
int dp[maxn][maxn][maxn], Next[maxn];
int pre[maxn][maxn][maxn][3], Len = 0, p, depth;
string ans;
void dfs(int i, int j, int k) {
  if (pre[i][j][k][0] == i - 1 && pre[i][j][k][1] == j - 1) depth++;
  if (depth < Len) {
    dfs(pre[i][j][k][0], pre[i][j][k][1], pre[i][j][k][2]);
  }
  if (pre[i][j][k][0] == i - 1 && pre[i][j][k][1] == j - 1) ans += s1[i];
}
void getNext() {
  int q, k;
  Next[0] = 0;
  for (q = 1, k = 0; q < lv; q++) {
    while (k && v[k] != v[q]) {
      k = Next[k - 1];
    }
    if (v[k] == v[q]) {
      k++;
    }
    Next[q] = k;
  }
}
void update(int i, int j, int k, int ii, int jj, int kk, int com) {
  if (dp[ii][jj][kk] == -1) return;
  if (dp[i][j][k] == -1 ||
      (dp[i][j][k] != -1 && dp[i][j][k] < dp[ii][jj][kk] + com)) {
    dp[i][j][k] = dp[ii][jj][kk] + com;
    pre[i][j][k][0] = ii;
    pre[i][j][k][1] = jj;
    pre[i][j][k][2] = kk;
  }
}
int main() {
  scanf("%s%s%s", s1 + 1, s2 + 1, v);
  l1 = strlen(s1 + 1);
  l2 = strlen(s2 + 1);
  lv = strlen(v);
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i <= l1; i++) {
    for (int j = 0; j <= l2; j++) {
      dp[i][j][0] = 0;
    }
  }
  getNext();
  for (int i = 1; i <= l1; i++) {
    for (int j = 1; j <= l2; j++) {
      for (int k = 0; k < lv; k++) {
        update(i, j, k, i - 1, j, k, 0);
        update(i, j, k, i, j - 1, k, 0);
      }
      if (s1[i] == s2[j]) {
        for (int k = 0; k < lv; k++) {
          int tmp;
          if (s1[i] == v[k]) {
            tmp = k + 1;
          } else {
            tmp = (k == 0 ? 0 : Next[k - 1]);
            while (tmp && s1[i] != v[tmp]) tmp = Next[tmp - 1];
            tmp = (v[tmp] == s1[i] ? tmp + 1 : 0);
          }
          update(i, j, tmp, i - 1, j - 1, k, 1);
        }
      }
    }
  }
  for (int i = 0; i < lv; i++) {
    if (Len < dp[l1][l2][i]) {
      Len = dp[l1][l2][p = i];
    }
  }
  if (!Len) {
    printf("0\n");
  } else {
    depth = 0;
    ans = "";
    dfs(l1, l2, p);
    cout << ans << endl;
  }
}