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>
inline T bigmod(T p, T e, T M) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T lcm(T a, T b) {
  a = abs(a);
  b = abs(b);
  return (a / gcd(a, b)) * b;
}
template <class T, class X>
inline bool getbit(T a, X i) {
  T t = 1;
  return ((a & (t << i)) > 0);
}
template <class T, class X>
inline T setbit(T a, X i) {
  T t = 1;
  return (a | (t << i));
}
template <class T, class X>
inline T resetbit(T a, X i) {
  T t = 1;
  return (a & (~(t << i)));
}
inline long long getnum() {
  char c = getchar();
  long long num, sign = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') sign = -1;
  for (num = 0; c >= '0' && c <= '9';) {
    c -= '0';
    num = num * 10 + c;
    c = getchar();
  }
  return num * sign;
}
inline long long power(long long a, long long b) {
  long long multiply = 1;
  for (int i = (0); i < (b); i++) {
    multiply *= a;
  }
  return multiply;
}
int dp[102][102][102];
string s1, s2, v;
int n, m, r;
string patt;
int pi[105];
void Process() {
  int j = -1;
  pi[0] = -1;
  for (int i = 1; i < r; i++) {
    while (j >= 0 && patt[i - 1] != patt[j]) j = pi[j];
    pi[i] = ++j;
  }
}
int prvidx(int x, int y) {
  while (y >= 0 && s1[x] != v[y]) y = pi[y];
  return y;
}
int calc(int i, int j, int k) {
  if (k == r) return -1e5;
  if (i == n || j == m) return 0;
  if (dp[i][j][k] != -1) return dp[i][j][k];
  int ret = max(calc(i + 1, j, k), calc(i, j + 1, k));
  if (s1[i] == s2[j]) {
    ret = max(ret, 1 + calc(i + 1, j + 1, prvidx(i, k) + 1));
  }
  return dp[i][j][k] = ret;
}
string ans = "";
void go(int rest, int i, int j, int k) {
  if (rest == 0) return;
  int t1 = calc(i + 1, j, k);
  int t2 = calc(i, j + 1, k);
  int t3 = -1e5;
  if (s1[i] == s2[j]) t3 = 1 + calc(i + 1, j + 1, prvidx(i, k) + 1);
  int ret = max(t1, max(t2, t3));
  if (ret == t1) {
    go(rest, i + 1, j, k);
  } else if (ret == t2) {
    go(rest, i, j + 1, k);
  } else if (ret == t3) {
    ans += s1[i];
    go(rest - 1, i + 1, j + 1, prvidx(i, k) + 1);
  }
}
int main() {
  int test, cases = 1;
  cin >> s1 >> s2 >> v;
  memset(dp, -1, sizeof(dp));
  n = s1.size();
  m = s2.size();
  r = v.size();
  patt = v;
  Process();
  int out = calc(0, 0, 0);
  if (!out)
    cout << 0 << "\n";
  else {
    go(out, 0, 0, 0);
    cout << ans << "\n";
  }
  return 0;
}