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
#include <bits/stdc++.h>
using namespace std;
template <class T1>
void deb(T1 e) {
  cout << e << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
long long sqr(long long n) { return n * n; }
double LOG(long long a, long long b) { return (log(a) / log(b)); }
long long GCD(long long a, long long b) {
  if (a < 0) return GCD(-a, b);
  if (b < 0) return GCD(a, -b);
  return (!b) ? a : GCD(b, a % b);
}
long long LCM(long long a, long long b) {
  if (a < 0) return LCM(-a, b);
  if (b < 0) return LCM(a, -b);
  return (a * (b / GCD(a, b)));
}
long long BigMod(long long B, long long P, long long M) {
  if (!P) return 1;
  if (!(P % 2)) return sqr(BigMod(B, P / 2, M)) % M;
  return (B % M) * (BigMod(B, P - 1, M)) % M;
}
int par[205];
int dp[105][105][105];
string s1, s2, vir;
string ans;
int rec(int x, int y, int z) {
  if (z == (int)vir.size()) return -(1 << 30);
  if (x == (int)s1.size() || y == (int)s2.size()) return 0;
  int &ret = dp[x][y][z];
  if (ret != -1) return ret;
  ret = rec(x + 1, y, z);
  ret = max(ret, rec(x, y + 1, z));
  if (s1[x] == s2[y]) {
    int k = z;
    while (k > 0 && s1[x] != vir[k]) k = par[k - 1];
    if (s1[x] == vir[k]) k++;
    ret = max(ret, rec(x + 1, y + 1, k) + 1);
  }
  return ret;
}
void prec(int x, int y, int z) {
  if (z == (int)vir.size()) return;
  if (x == (int)s1.size() || y == (int)s2.size()) return;
  int &ret = dp[x][y][z];
  if (ret == rec(x + 1, y, z)) return prec(x + 1, y, z);
  if (ret == rec(x, y + 1, z)) return prec(x, y + 1, z);
  if (s1[x] == s2[y]) {
    int k = z;
    while (k > 0 && s1[x] != vir[k]) k = par[k - 1];
    if (s1[x] == vir[k]) k++;
    if (ret == rec(x + 1, y + 1, k) + 1) {
      ans += s1[x];
      return prec(x + 1, y + 1, k);
    }
  }
  return;
}
int main(void) {
  cin >> s1 >> s2 >> vir;
  memset(par, 0, sizeof(par));
  int k = 0;
  string cur = vir;
  for (int i = 1; i < (int)cur.size(); i++) {
    while (k > 0 && cur[i] != cur[k]) k = par[k - 1];
    if (cur[i] == cur[k]) k++;
    par[i] = k;
  }
  memset(dp, -1, sizeof(dp));
  int res = rec(0, 0, 0);
  if (!res) {
    deb(res);
    return 0;
  }
  ans = "";
  prec(0, 0, 0);
  deb(ans);
  return 0;
}
