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;
int dp[maxn][maxn][maxn], pre[maxn][maxn][maxn][3];
char s1[maxn], s2[maxn], vir[maxn];
char ans[maxn];
int nxt[maxn];
int n, m, t;
inline void getm(int x, int y, int z, int x1, int y1, int z1, int v) {
  if (dp[x1][y1][z1] + v > dp[x][y][z]) {
    dp[x][y][z] = dp[x1][y1][z1] + v;
    pre[x][y][z][0] = x1;
    pre[x][y][z][1] = y1;
    pre[x][y][z][2] = z1;
  }
}
void get_next() {
  nxt[0] = nxt[1] = 0;
  for (int i = 1; i < t; ++i) {
    int j = nxt[i];
    while (j > 0 && vir[i] != vir[j]) j = nxt[j];
    if (vir[i] == vir[j]) j++;
    nxt[i + 1] = j;
  }
}
int main() {
  scanf("%s", s1);
  scanf("%s", s2);
  scanf("%s", vir);
  n = strlen(s1);
  m = strlen(s2);
  t = strlen(vir);
  get_next();
  memset(dp, 0xff, sizeof(dp));
  memset(pre, 0xff, sizeof(pre));
  dp[0][0][0] = 0;
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= m; ++j)
      for (int k = 0; k < t; ++k) {
        getm(i + 1, j, k, i, j, k, 0);
        getm(i, j + 1, k, i, j, k, 0);
        if (dp[i][j][k] >= 0 && s1[i] == s2[j]) {
          if (s1[i] == vir[k]) {
            getm(i + 1, j + 1, k + 1, i, j, k, 1);
          } else {
            int p = nxt[k];
            while (p > 0 && s1[i] != vir[p]) p = nxt[p];
            getm(i + 1, j + 1, p + (s1[i] == vir[p]), i, j, k, 1);
          }
        }
      }
  int x, y, z, maxv = -1;
  for (int k = 0; k < t; ++k)
    if (dp[n][m][k] > maxv) {
      maxv = dp[n][m][k];
      z = k;
    }
  if (maxv <= 0)
    printf("0\n");
  else {
    x = n;
    y = m;
    int len = maxv;
    while (pre[x][y][z][0] != -1) {
      int xx, yy, zz;
      xx = pre[x][y][z][0];
      yy = pre[x][y][z][1];
      zz = pre[x][y][z][2];
      if (x - xx == 1 && y - yy == 1 && s1[x - 1] == s2[y - 1])
        ans[maxv--] = s1[x - 1];
      x = xx;
      y = yy;
      z = zz;
    }
    for (int i = 1; i <= len; ++i) printf("%c", ans[i]);
    printf("\n");
  }
  return 0;
}