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>
struct state {
  int n : 24;
  int c : 8;
  state const *prev;
};
state b[128][128][128] = {};
void print(state const &s) {
  if (s.n) {
    state const &p = *s.prev;
    print(p);
    if (p.n < s.n) printf("%c", s.c);
  }
}
int main() {
  char s1[128];
  char s2[128];
  char sv[128];
  scanf("%s%s%s", s1, s2, sv);
  unsigned int n1 = strlen(s1);
  unsigned int n2 = strlen(s2);
  unsigned int nv = strlen(sv);
  unsigned int fail[128] = {};
  for (unsigned int i = 1, j = 0; i < nv;)
    if (sv[i] == sv[j])
      fail[i++] = 1 + j++;
    else if (0 < j)
      j = fail[j - 1];
    else
      fail[i++] = 0;
  b[0][0][0].n = 0;
  for (unsigned int i = 1; i <= nv; ++i) b[0][0][i].n = -4200;
  for (unsigned int i = 1; i <= n1; ++i) {
    for (unsigned int j = 1; j <= n2; ++j) {
      for (unsigned int k = 0; k < nv; ++k) {
        b[i][j][k] = b[i - 1][j][k];
        if (b[i][j][k].n < b[i][j - 1][k].n) b[i][j][k] = b[i][j - 1][k];
      }
      if (s1[i - 1] == s2[j - 1]) {
        for (unsigned int k = 0; k < nv; ++k) {
          unsigned int v = k;
          while (1) {
            if (s1[i - 1] == sv[v]) {
              ++v;
              break;
            }
            if (0 < v)
              v = fail[v - 1];
            else
              break;
          }
          if (b[i][j][v].n < b[i - 1][j - 1][k].n + 1) {
            b[i][j][v].n = b[i - 1][j - 1][k].n + 1;
            b[i][j][v].c = s1[i - 1];
            b[i][j][v].prev = &b[i - 1][j - 1][k];
          }
        }
      }
    }
  }
  unsigned int v = 0;
  for (unsigned int i = 1; i < nv; ++i)
    if (b[n1][n2][v].n < b[n1][n2][i].n) v = i;
  if (0 < b[n1][n2][v].n) {
    print(b[n1][n2][v]);
    printf("\n");
  } else
    printf("0\n");
}