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;
int Set(int n, int pos) { return n = n | (1 << pos); }
int reset(int n, int pos) { return n = n & ~(1 << pos); }
bool check(int n, int pos) { return (bool)(n & (1 << pos)); }
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
};
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); };
char x[105], y[105], virus[105];
int p[105], dp[105][105][105], xlen, ylen, vlen;
void prefix(char* ss) {
  int len = strlen(ss);
  int j = 0;
  for (int i = 1; i < len; i++) {
    while (j > 0 && ss[j] != ss[i]) j = p[j - 1];
    if (ss[i] == ss[j]) ++j;
    p[i] = j;
  }
}
int calc(int i, int j, int k) {
  if (i == xlen || j == ylen || k == vlen) return 0;
  if (dp[i][j][k] != -1) return dp[i][j][k];
  int f1 = 0, f2 = 0, f3 = 0, tmp = k;
  f1 = calc(i + 1, j, k);
  f2 = calc(i, j + 1, k);
  if (x[i] == y[j]) {
    while (tmp > 0 && x[i] != virus[tmp]) tmp = p[tmp - 1];
    if (x[i] == virus[tmp]) ++tmp;
    if (tmp < vlen) f3 = calc(i + 1, j + 1, tmp) + 1;
  }
  dp[i][j][k] = max(f1, max(f2, f3));
  return dp[i][j][k];
}
int ans;
void print(int i, int j, int k) {
  if (i == xlen || j == ylen || k >= vlen) return;
  int tmp = k;
  if (dp[i][j][k] == dp[i + 1][j][k])
    print(i + 1, j, k);
  else if (dp[i][j][k] == dp[i][j + 1][k])
    print(i, j + 1, k);
  else {
    if (x[i] == y[j]) {
      printf("%c", x[i]);
      while (tmp > 0 && x[i] != virus[tmp]) tmp = p[tmp - 1];
      if (x[i] == virus[tmp]) ++tmp;
      if (tmp < vlen && dp[i][j][k] == dp[i + 1][j + 1][tmp] + 1) {
        print(i + 1, j + 1, tmp);
        return;
      }
    }
  }
}
int main() {
  scanf("%s %s %s", x, y, virus);
  xlen = strlen(x), ylen = strlen(y), vlen = strlen(virus);
  prefix(virus);
  memset(dp, -1, sizeof(dp));
  ans = calc(0, 0, 0);
  if (ans)
    print(0, 0, 0);
  else
    printf("0\n");
  return 0;
}