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;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int oo = 0x3f3f3f3f;
const int maxn = 100;
char sa[maxn + 5], sb[maxn + 5], sc[maxn + 5];
int na, nb, nc;
int nxt[maxn + 5];
int dp[maxn + 5][maxn + 5][maxn + 5];
struct data {
  int i, j, k;
  data() {}
  data(int _i, int _j, int _k) : i(_i), j(_j), k(_k) {}
};
data pre[maxn + 5][maxn + 5][maxn + 5];
inline void get_nxt(char *a, int n, int *nxt) {
  int i = 1, j = 0;
  while (i < n) {
    while (j && a[i] != a[j]) j = nxt[j];
    if (a[i] == a[j]) ++j;
    ++i;
    nxt[i] = j;
  }
}
int main() {
  scanf("%s", sa), na = strlen(sa);
  scanf("%s", sb), nb = strlen(sb);
  scanf("%s", sc), nc = strlen(sc);
  memset(dp, -1, sizeof dp);
  get_nxt(sc, nc, nxt);
  dp[0][0][0] = 0;
  pre[0][0][0] = data(-1, -1, -1);
  for (int i = (0), _end_ = (na + 1); i < _end_; ++i)
    for (int j = (0), _end_ = (nb + 1); j < _end_; ++j)
      for (int k = (0), _end_ = (nc); k < _end_; ++k)
        if (dp[i][j][k] >= 0) {
          if (i < na && chkmax(dp[i + 1][j][k], dp[i][j][k]))
            pre[i + 1][j][k] = data(i, j, k);
          if (j < nb && chkmax(dp[i][j + 1][k], dp[i][j][k]))
            pre[i][j + 1][k] = data(i, j, k);
          if (i < na && j < nb && sa[i] == sb[j]) {
            int new_k = k;
            if (sa[i] == sc[new_k])
              ++new_k;
            else {
              while (new_k && sc[new_k] != sa[i]) new_k = nxt[new_k];
              if (sc[new_k] == sa[i]) ++new_k;
            }
            if (new_k < nc) {
              if (chkmax(dp[i + 1][j + 1][new_k], dp[i][j][k] + 1))
                pre[i + 1][j + 1][new_k] = data(i, j, k);
            }
          }
        }
  int ans = -1;
  data now = data(na, nb, -1);
  for (int i = (0), _end_ = (nc); i < _end_; ++i)
    if (chkmax(ans, dp[na][nb][i])) now = data(na, nb, i);
  if (ans == 0)
    printf("0\n");
  else {
    static char ret[maxn + 5];
    int retn = 0;
    while (now.i != -1) {
      data tmp = pre[now.i][now.j][now.k];
      if (tmp.i >= 0 && now.i != tmp.i && now.j != tmp.j)
        ret[retn++] = sa[tmp.i];
      now = tmp;
    }
    reverse(ret, ret + retn);
    ret[retn] = 0;
    printf("%s\n", ret);
  }
  return 0;
}