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;
inline void pisz(int n) { printf("%d\n", n); }
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, -1, 0, 1};
const int drr[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int dcc[8] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename TT>
ostream& operator<<(ostream& s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, vector<T> t) {
  for (int i = 0; i < ((int)((t).size())); i++) s << t[i] << " ";
  return s;
}
class UnionFind {
 private:
  vector<int> rank, p;

 public:
  UnionFind(int n) {
    for (int i = 0; i < n; i++) p.push_back(i);
    rank.assign(n, 0);
  }
  int findSet(int s) { return (p[s] == s) ? s : (p[s] = findSet(p[s])); }
  bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
  void unionSet(int i, int j) {
    if (isSameSet(i, j)) return;
    int x = findSet(i), y = findSet(j);
    if (rank[x] > rank[y])
      p[y] = x;
    else {
      p[x] = y;
      if (rank[x] == rank[y]) rank[y]++;
    }
  }
};
bool fcomp(double A, double B) {
  double EPSILON = numeric_limits<double>::epsilon();
  double diff = A - B;
  return fabs(diff) < EPSILON;
}
double x_y(int x1, int y1, int x2, int y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
const int K = 26;
struct Vertex {
  int next[K];
  bool terminal = false;
  int terminal_idx = -1;
  int p = -1;
  char pch;
  int depth = 0;
  int link = 0;
  int next_terminal = 0;
  Vertex(int p, char ch, int depth) : p(p), pch(ch), depth(depth) {
    for (int i = 0; i < K; i++) next[i] = 0;
  }
};
vector<Vertex> t(1, {-1, '$', 0});
void add_string(std::string const& s, int idx) {
  int v = 0;
  for (char ch : s) {
    int c = ch - 'A';
    if (!t[v].next[c]) {
      t[v].next[c] = t.size();
      t.emplace_back(v, ch, t[v].depth + 1);
    }
    v = t[v].next[c];
  }
  t[v].terminal = true;
  t[v].terminal_idx = idx;
}
void push_links() {
  std::queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int v = q.front();
    auto& cur = t[v];
    auto& link = t[cur.link];
    q.pop();
    cur.next_terminal = link.terminal ? cur.link : link.next_terminal;
    for (int c = 0; c < K; c++) {
      if (cur.next[c]) {
        t[cur.next[c]].link = v ? link.next[c] : 0;
        q.push(cur.next[c]);
      } else {
        cur.next[c] = link.next[c];
      }
    }
  }
}
int go(int idx, char c) { return t[idx].next[c - 'A']; }
Vertex const& getInfo(int idx) { return t[idx]; }
int dp[105][105][3000];
string s1, s2, virus;
int rec(int i, int j, int v) {
  if (t[v].next_terminal || t[v].terminal) return -1e8;
  if (i == (int)s1.size() || j == (int)s2.size()) return 0;
  int &ret = dp[i][j][v], res = -1e8;
  if (ret != -1) return ret;
  res = (res < rec(i + 1, j, v) ? rec(i + 1, j, v) : res);
  res = (res < rec(i, j + 1, v) ? rec(i, j + 1, v) : res);
  if (s1[i] == s2[j])
    res = (res < 1 + rec(i + 1, j + 1, go(v, s1[i]))
               ? 1 + rec(i + 1, j + 1, go(v, s1[i]))
               : res);
  return ret = res;
}
void printP(int i, int j, int v, int rem) {
  if (i == (int)s1.size() || j == (int)s2.size()) {
    printf("\n");
    return;
  }
  if (rec(i + 1, j, v) == rem) {
    printP(i + 1, j, v, rem);
    return;
  }
  if (rec(i, j + 1, v) == rem) {
    printP(i, j + 1, v, rem);
    return;
  }
  if (s1[i] == s2[j]) {
    if (1 + rec(i + 1, j + 1, go(v, s1[i])) == rem) {
      cout << s1[i];
      printP(i + 1, j + 1, go(v, s1[i]), rem - 1);
    }
  }
}
int main() {
  cin >> s1 >> s2 >> virus;
  add_string(virus, 0);
  push_links();
  memset(dp, -1, sizeof(dp));
  int ans = rec(0, 0, 0);
  if (!ans)
    cout << ans << endl;
  else
    printP(0, 0, 0, ans);
  return 0;
}