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 MAXL(100);
int s1[MAXL + 1], s2[MAXL + 1], virus[MAXL + 2], nxt[MAXL + 1],
    ac[MAXL + 1][26];
int dp[MAXL + 1][MAXL + 1][MAXL + 1], plan[MAXL + 1][MAXL + 1][MAXL + 1];
char str[MAXL + 2];
int Read(int* const p) {
  int c, len(0);
  do c = getchar();
  while (!((c) >= 'A' && (c) <= 'Z'));
  while (((c) >= 'A' && (c) <= 'Z')) {
    p[++len] = c - 'A';
    c = getchar();
  }
  return len;
}
int main() {
  int l1, l2, lv, t;
  int ans(0), x, y, z;
  l1 = Read(s1);
  l2 = Read(s2);
  lv = Read(virus);
  virus[lv + 1] = -1;
  t = 0;
  for (int i = 2; i <= lv; ++i) {
    while (t && virus[i] != virus[t + 1]) t = nxt[t];
    virus[i] == virus[t + 1] && ++t;
    nxt[i] = t;
  }
  ac[0][virus[1]] = 1;
  for (int j = 0; j < 26; ++j)
    for (int i = 1; i <= lv; ++i)
      ac[i][j] = virus[i + 1] == j ? i + 1 : ac[nxt[i]][j];
  for (int i = 1; i <= l1; ++i)
    for (int j = 1; j <= l2; ++j)
      for (int k = 0; k < lv; ++k) {
        dp[i][j][k] < dp[i - 1][j][k] &&
            (dp[i][j][k] = dp[i - 1][j][k], plan[i][j][k] = 1);
        dp[i][j][k] < dp[i][j - 1][k] &&
            (dp[i][j][k] = dp[i][j - 1][k], plan[i][j][k] = 2);
        s1[i] == s2[j] && (((t = ac[k][s1[i]]) || true) && t < lv) &&
            dp[i][j][t] < dp[i - 1][j - 1][k] + 1 &&
            (dp[i][j][t] = dp[i - 1][j - 1][k] + 1, plan[i][j][t] = k + 3);
      }
  for (int i = 0; i < lv; ++i)
    if (ans < dp[l1][l2][i]) {
      ans = dp[l1][l2][i];
      t = i;
    }
  if (!ans) {
    printf("0\n");
    return 0;
  }
  x = l1, y = l2, z = t;
  for (int i = 1; i <= ans;) switch (plan[x][y][z]) {
      case 1:
        --x;
        break;
      case 2:
        --y;
        break;
      default:
        str[ans - i + 1] = s1[x] + 'A';
        z = plan[x][y][z] - 3;
        --x;
        --y;
        ++i;
        break;
    }
  printf("%s\n", str + 1);
  return 0;
}