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>
char s1[101], s2[101], v[101];
int m, n, l, AT[26][102], DT[110][110][110];
inline int max(int a, int b) { return a > b ? a : b; }
inline void make_table() {
  int i, j, k, kk;
  for (i = 0; i < l; i++) AT[v[i] - 'A'][i] = i + 1;
  for (i = 1; i < l; i++) {
    for (j = 'A'; j <= 'Z'; j++) {
      if (!AT[j - 'A'][i]) {
        for (k = i - 1; k >= 0; k--) {
          if (j == (int)v[k]) {
            for (kk = 1; kk <= k && v[i - kk] == v[k - kk]; kk++)
              ;
            if (kk > k) {
              AT[j - 'A'][i] = k + 1;
              break;
            }
          }
        }
      }
    }
  }
}
int solve(int a, int b, int c) {
  if (c == l) return DT[a][b][c] = -100;
  if (a == n || b == m) return DT[a][b][c] = 0;
  if (DT[a][b][c] == -1) {
    DT[a][b][c] = max(solve(a + 1, b, c), solve(a, b + 1, c));
    if (s1[a] == s2[b])
      DT[a][b][c] =
          max(DT[a][b][c], solve(a + 1, b + 1, AT[s1[a] - 'A'][c]) + 1);
  }
  return DT[a][b][c];
}
void prt(int a, int b, int c) {
  if (a == n || b == m) return;
  if (DT[a + 1][b][c] == DT[a][b][c])
    prt(a + 1, b, c);
  else if (DT[a][b + 1][c] == DT[a][b][c])
    prt(a, b + 1, c);
  else {
    printf("%c", s1[a]);
    prt(a + 1, b + 1, AT[s1[a] - 'A'][c]);
  }
}
int ans;
int main() {
  memset(DT, -1, sizeof(DT));
  scanf("%s%s%s", s1, s2, v);
  n = strlen(s1), m = strlen(s2), l = strlen(v);
  make_table();
  ans = solve(0, 0, 0);
  if (!ans)
    printf("%d\n", ans);
  else
    prt(0, 0, 0), puts("");
}