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>
T sqr(T x) {
  return x * x;
}
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
template <class T>
inline T bigmod(T p, T e, T M) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    long long int t = bigmod(p, e / 2, M);
    return (T)((t * t) % M);
  }
  return (T)((long long int)bigmod(p, e - 1, M) * (long long int)p) % M;
}
template <class T>
inline T bigexp(T p, T e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    long long int t = bigexp(p, e / 2);
    return (T)((t * t));
  }
  return (T)((long long int)bigexp(p, e - 1) * (long long int)p);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
int dx4[] = {1, 0, -1, 0};
int dy4[] = {0, 1, 0, -1};
int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
int nx8[] = {1, 1, -1, -1, 2, 2, -2, -2};
int ny8[] = {2, -2, 2, -2, 1, -1, 1, -1};
int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int n, dp[102][102][102], la, lb, lv, T[102], path[102][102][102];
char s[102], s1[102], vir[105];
int call(int i, int j, int p) {
  if (p >= lv) return -10000;
  if (i >= la || j >= lb) {
    return 0;
  }
  if (dp[i][j][p] != -1) return dp[i][j][p];
  int ret = 0, cnd, tmp;
  if (s[i] == s1[j]) {
    cnd = p;
    while (vir[cnd] != s[i] && cnd > 0) cnd = T[cnd];
    if (vir[cnd] == s[i]) {
      tmp = 1 + call(i + 1, j + 1, cnd + 1);
      if (ret < tmp) {
        path[i][j][p] = 1;
        ret = tmp;
      }
    } else {
      tmp = 1 + call(i + 1, j + 1, 0);
      if (ret < tmp) {
        path[i][j][p] = 1;
        ret = tmp;
      }
    }
  }
  tmp = call(i + 1, j, p);
  if (ret < tmp) {
    path[i][j][p] = 2;
    ret = tmp;
  }
  tmp = call(i, j + 1, p);
  if (ret < tmp) {
    path[i][j][p] = 3;
    ret = tmp;
  }
  return dp[i][j][p] = ret;
}
void print(int i, int j, int p) {
  if (s[i] == '\0' || s1[j] == '\0' || vir[p] == '\0') return;
  if (path[i][j][p] == -1) return;
  if (path[i][j][p] == 1) {
    if (s[i] == s1[j]) {
      printf("%c", s[i]);
      int cnd = p;
      while (vir[cnd] != s[i] && cnd > 0) cnd = T[cnd];
      if (s[i] == vir[cnd])
        print(i + 1, j + 1, cnd + 1);
      else
        print(i + 1, j + 1, 0);
    }
  } else if (path[i][j][p] == 2)
    print(i + 1, j, p);
  else if (path[i][j][p] == 3)
    print(i, j + 1, p);
}
int main() {
  memset(dp, -1, sizeof dp);
  memset(path, -1, sizeof path);
  scanf("%s", &s);
  scanf("%s", &s1);
  scanf("%s", &vir);
  la = strlen(s);
  lb = strlen(s1);
  lv = strlen(vir);
  T[0] = T[1] = 0;
  int pos = 2, cnd = 0;
  while (pos < lv) {
    if (vir[pos - 1] == vir[cnd]) {
      T[pos] = cnd + 1;
      cnd += 1;
      pos += 1;
    } else if (cnd > 0)
      cnd = T[cnd];
    else {
      T[pos] = 0;
      pos += 1;
    }
  }
  int res = call(0, 0, 0);
  if (res == 0)
    printf("0");
  else
    print(0, 0, 0);
  return 0;
}