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 <class T>
inline bool Up(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool Down(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
inline int getus() {
  int tmp, c;
  while (tmp = fgetc(stdin), tmp < '0' || tmp > '9')
    ;
  tmp -= '0';
  while (c = fgetc(stdin), '0' <= c && c <= '9') tmp = tmp * 10 + c - '0';
  return tmp;
}
inline int getint() {
  int tmp, c, flag;
  while (flag = fgetc(stdin), flag != '-' && (flag < '0' || flag > '9'))
    ;
  if (flag == '-')
    tmp = 0;
  else
    tmp = flag - '0';
  while (c = fgetc(stdin), '0' <= c && c <= '9') tmp = tmp * 10 + c - '0';
  return flag == '-' ? -tmp : tmp;
}
const int MAXN = 10023;
struct triple {
  int x, y, pos;
  triple() : x(-1), y(-1), pos(-1) {}
  triple(int x, int y, int pos) : x(x), y(y), pos(pos) {}
} last[133][133][133];
struct node {
  node *fail, *next[26];
  node() {}
} base[MAXN], *top = base, *root;
typedef node *tree;
inline tree newNode() {
  memset(top, 0, sizeof(node));
  return top++;
}
void insertTrie(char *s) {
  tree t = root;
  for (; *s; ++s) {
    int d = *s - 'A';
    if (!t->next[d]) t->next[d] = newNode();
    t = t->next[d];
  }
}
void construct() {
  static tree Q[MAXN];
  int h = 0, t = 0;
  root->fail = root;
  for (Q[++t] = root; h < t;) {
    tree x = Q[++h];
    for (int d = (0); d < (26); ++d)
      if (!x->next[d])
        x->next[d] = (x == root) ? (root) : (x->fail->next[d]);
      else {
        x->next[d]->fail = (x == root) ? (root) : (x->fail->next[d]);
        Q[++t] = x->next[d];
      }
  }
}
int LA, LB, LS, dp[133][133][133];
char A[MAXN], B[MAXN], S[MAXN];
void DFS(int i, int j, int pos) {
  if (i == 0 && j == 0 && pos == 0) return;
  int x = last[i][j][pos].x;
  int y = last[i][j][pos].y;
  int k = last[i][j][pos].pos;
  DFS(x, y, k);
  if (x + 1 == i && y + 1 == j) {
    assert(A[i] == B[j]);
    putchar(A[i]);
  }
}
int main() {
  scanf("%s", A + 1);
  LA = strlen(A + 1);
  scanf("%s", B + 1);
  LB = strlen(B + 1);
  scanf("%s", S + 1);
  LS = strlen(S + 1);
  root = newNode();
  insertTrie(S + 1);
  construct();
  memset(dp, -63, sizeof(dp));
  for (int i = (0); i < (133); ++i)
    for (int j = (0); j < (133); ++j)
      for (int k = (0); k < (133); ++k) last[i][j][k] = triple(-1, -1, -1);
  dp[0][0][root - base] = 0;
  int Ncnt = top - base;
  for (int i = (0); i <= (LA); ++i)
    for (int j = (0); j <= (LB); ++j)
      for (int pos = (0); pos < (Ncnt); ++pos) {
        int v = dp[i][j][pos];
        triple now(i, j, pos);
        if (v <= -1000000000) continue;
        if (i + 1 <= LA)
          if (Up(dp[i + 1][j][pos], v)) last[i + 1][j][pos] = now;
        if (j + 1 <= LB)
          if (Up(dp[i][j + 1][pos], v)) last[i][j + 1][pos] = now;
        if (i + 1 <= LA && j + 1 <= LB && A[i + 1] == B[j + 1] &&
            base[pos].next[A[i + 1] - 'A'] != (top - 1)) {
          int index = base[pos].next[A[i + 1] - 'A'] - base;
          if (Up(dp[i + 1][j + 1][index], v + 1))
            last[i + 1][j + 1][index] = now;
        }
      }
  int ans = -1, x = -1, y = -1, p = -1;
  for (int i = (0); i <= (LA); ++i)
    for (int j = (0); j <= (LB); ++j)
      for (int pos = (0); pos < (Ncnt); ++pos)
        if (Up(ans, dp[i][j][pos])) {
          x = i;
          y = j;
          p = pos;
        }
  if (ans == 0) {
    puts("0");
    return 0;
  }
  DFS(x, y, p);
  puts("");
  return 0;
}