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;
struct FASTINPUT {
  void f(string& s) {
    char buf[200005];
    long long a = scanf("%s", buf);
    a++;
    s = buf;
  }
  void f(long long& x) {
    long long a = scanf("%lld", &x);
    a++;
  }
  void f(int& x) {
    long long a = scanf("%d", &x);
    a++;
  }
  template <typename A, typename B>
  void f(pair<A, B>& p) {
    f(p.first);
    f(p.second);
  }
  template <typename A>
  void f(vector<A>& x) {
    for (auto& y : x) f(y);
  }
  void read() {}
  template <typename Head, typename... Tail>
  void read(Head& H, Tail&... T) {
    f(H);
    read(T...);
  }
};
struct FASTOUTPUT {
  void f(string s) { printf("%s", s.c_str()); }
  void f(long long x) { printf("%lld", x); }
  void f(int x) { printf("%d", x); }
  void f(char x) { printf("%c", x); }
  void f(const char* a) { printf("%s", a); }
  void print() {}
  template <typename Head, typename... Tail>
  void print(Head H, Tail... T) {
    f(H);
    print(T...);
  }
};
struct DEBUG {
  string open = "[", close = "]", sep = ", ";
  string f(string s) { return s; }
  string f(char c) { return string(1, c); }
  string f(int x) { return to_string(x); }
  string f(long long x) { return to_string(x); }
  string f(double x) { return to_string(x); }
  string f(const char* a) { return a; }
  template <typename A, typename B>
  string f(pair<A, B> p) {
    return open + f(p.first) + sep + f(p.second) + close;
  }
  template <typename A>
  string f(A v) {
    string s = open;
    for (auto a : v) {
      if (s != open) {
        s += sep;
      }
      s += f(a);
    }
    s += close;
    return s;
  }
  void show() { cout << endl; }
  template <typename Head, typename... Tail>
  void show(Head H, Tail... T) {
    cout << " " << f(H);
    show(T...);
  }
};
vector<long long> di = {0, 0, 1, -1, 1, -1, 1, -1};
vector<long long> dj = {1, -1, 0, 0, -1, -1, 1, 1};
long long ob(long long i, long long n) { return i < 0 || i >= n; }
long long tp(long long x) { return (1LL << x); }
long long roundup(long long a, long long b) {
  return a % b ? a / b + 1 : a / b;
}
template <typename A, typename B>
long long exist(A a, B b) {
  return a.find(b) != a.end();
}
vector<string> ssplit(string s) {
  vector<string> ans;
  stringstream ss;
  ss << s;
  while (ss >> s) ans.push_back(s);
  return ans;
}
void upmin(long long& x, long long v) { x = min(x, v); }
void upmax(long long& x, long long v) { x = max(x, v); }
const long long inf = (long long)1e18 + 5;
const long long mod = 1e9 + 7;
const long long mod2 = 998244353;
const double eps = 1e-10;
const string nl = "\n";
string a, b, c;
vector<long long> kmp(string s) {
  long long n = s.length();
  vector<long long> k(n);
  for (long long i = 1; i < n; i++) {
    long long prev = k[i - 1];
    while (prev && s[i] != s[prev]) {
      prev = k[prev - 1];
    }
    k[i] = prev + (s[i] == s[prev]);
  }
  return k;
}
long long ac[105][26];
long long nextind(long long i, char x) {
  if (ac[i][x - 'A'] != -1) return ac[i][x - 'A'];
  string s = c.substr(0, i);
  s.push_back(x);
  vector<long long> k = kmp(c + "$" + s);
  ac[i][x - 'A'] = k.back();
  return k.back();
}
long long dp[105][105][105];
long long get(long long i, long long j, long long k) {
  if (k == (long long)c.length()) return -inf;
  if (i == (long long)a.length() || j == (long long)b.length()) return 0;
  if (dp[i][j][k] != -1) return dp[i][j][k];
  long long ans = -inf;
  if (a[i] == b[j]) {
    upmax(ans, 1 + get(i + 1, j + 1, nextind(k, a[i])));
  }
  upmax(ans, get(i + 1, j, k));
  upmax(ans, get(i, j + 1, k));
  dp[i][j][k] = ans;
  return ans;
}
string ans;
void bt(long long i, long long j, long long k) {
  long long exp = get(i, j, k);
  if (exp == 0) return;
  if (a[i] == b[j]) {
    if (exp == 1 + get(i + 1, j + 1, nextind(k, a[i]))) {
      ans.push_back(a[i]);
      bt(i + 1, j + 1, nextind(k, a[i]));
      return;
    }
  }
  if (exp == get(i + 1, j, k)) {
    bt(i + 1, j, k);
    return;
  }
  bt(i, j + 1, k);
}
void solve() {
  do {
    FASTINPUT inp;
    inp.read(a, b, c);
  } while (false);
  memset(dp, -1, sizeof(dp));
  memset(ac, -1, sizeof(ac));
  long long best = -inf;
  long long ind = -inf;
  for (long long i = 0; i < (long long)c.length(); i++) {
    long long cur = get(0, 0, i);
    if (cur > best) {
      best = cur;
      ind = i;
    }
  }
  if (best == 0) {
    do {
      FASTOUTPUT out;
      out.print(0, nl);
    } while (false);
    return;
  }
  bt(0, 0, ind);
  do {
    FASTOUTPUT out;
    out.print(ans, nl);
  } while (false);
}
signed main() {
  long long t = 1;
  for (long long i = 0; i < t; i++) solve();
  return 0;
}
