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;
char a[103], b[103], v[103];
int aa, bb, vv;
int dp[103][103][103], d[103];
int func(int l, char c) {
  while (l > 0 && v[l] != c) l = d[l - 1];
  if (v[l] == c) l++;
  return l;
}
int ans(int i, int j, int k) {
  if (i == aa || j == bb) return 0;
  int &rlt = dp[i][j][k];
  if (rlt != -1) return rlt;
  rlt = max(ans(i, j + 1, k), ans(i + 1, j, k));
  if (a[i] == b[j]) {
    int kk = func(k, a[i]);
    if (kk < vv) rlt = max(rlt, ans(i + 1, j + 1, kk) + 1);
  }
  return rlt;
}
void scan(int i, int j, int k) {
  if (i == aa || j == bb) return;
  int res = ans(i, j, k);
  if (res == ans(i, j + 1, k)) return scan(i, j + 1, k);
  if (res == ans(i + 1, j, k)) return scan(i + 1, j, k);
  printf("%c", a[i]);
  scan(i + 1, j + 1, func(k, a[i]));
}
int main() {
  int i, j, k;
  memset(dp, -1, sizeof dp);
  scanf("%s %s %s", a, b, v);
  aa = strlen(a);
  bb = strlen(b);
  vv = strlen(v);
  int l = 0;
  for (int i = 1; i < vv; i++) {
    l = func(l, v[i]);
    d[i] = l;
  }
  k = ans(0, 0, 0);
  if (k == 0)
    puts("0");
  else
    scan(0, 0, 0);
}