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;
const int CHR = 30;
struct node {
  int nxt[CHR];
  node() { memset(nxt, 0, sizeof(nxt)); }
};
node T[209];
int fl[209];
int nw;
int val[209];
void init() {
  memset(T, 0, sizeof(T));
  memset(fl, 0, sizeof(fl));
  memset(val, 0, sizeof(val));
  T[1] = node();
  nw = 1;
}
void Ins(string s, int ln, int vl) {
  int p = 1;
  for (int i = 0; i < ln; i++) {
    int k = s[i] - 'A';
    if (T[p].nxt[k] == 0) {
      T[p].nxt[k] = (++nw);
      T[nw] = node();
    }
    p = T[p].nxt[k];
  }
  val[p] += vl;
}
void fail_bfs() {
  queue<int> Q;
  Q.push(1);
  for (int i = 0; i < CHR; i++) T[0].nxt[i] = 1;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i = 0; i < CHR; i++) {
      int v = T[u].nxt[i];
      if (v == 0) {
        T[u].nxt[i] = T[fl[u]].nxt[i];
        continue;
      }
      fl[v] = T[fl[u]].nxt[i];
      Q.push(v);
    }
  }
}
string vrs, a, b;
int la, lb, lv;
int dp[209][209][209];
int go(int i, int j, int id) {
  if (i == la || j == lb) return 0;
  int &ret = dp[i][j][id];
  if (ret != -1) return ret;
  ret = 0;
  int op1 = go(i + 1, j, id);
  int op2 = go(i, j + 1, id);
  int op3 = 0;
  if (a[i] == b[j]) {
    int cst = 0, nid = T[id].nxt[a[i] - 'A'];
    int tmp = nid;
    while (tmp) cst += val[tmp], tmp = fl[tmp];
    if (!cst) op3 = 1 + go(i + 1, j + 1, nid);
  }
  ret = max(ret, max(max(op1, op2), op3));
  return ret;
}
void po(int i, int j, int id) {
  if (i == la || j == lb) return;
  int &ret = dp[i][j][id];
  if (ret == go(i + 1, j, id)) {
    po(i + 1, j, id);
    return;
  } else if (ret == go(i, j + 1, id)) {
    po(i, j + 1, id);
    return;
  } else if (a[i] == b[j]) {
    int cst = 0, nid = T[id].nxt[a[i] - 'A'];
    int tmp = nid;
    while (tmp) cst += val[tmp], tmp = fl[tmp];
    if (!cst) {
      if (ret = 1 + go(i + 1, j + 1, nid)) {
        cout << a[i];
        po(i + 1, j + 1, nid);
        return;
      }
    }
  }
  return;
}
int main() {
  int i, j, k;
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> a >> b >> vrs;
  init();
  la = a.size();
  lb = b.size();
  lv = vrs.size();
  Ins(vrs, lv, 2);
  fail_bfs();
  memset(dp, -1, sizeof(dp));
  int ans = go(0, 0, 1);
  if (ans == 0)
    cout << 0 << endl;
  else
    po(0, 0, 1), cout << endl;
  ;
  return 0;
}