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;
struct node {
  node* next = nullptr;
  node* fail = nullptr;
  char c;
  int index;
  node(int i, char s) : index(i), c(s) {}
};
node* root = new node(0, '#');
node* go(node* f, char c) {
  while (f && f->next->c != c) {
    f = f->fail;
  }
  return f ? f->next : root;
}
string s, w, vi;
int n, m, k;
vector<vector<vector<int>>> dp;
int calc(int i = 0, int j = 0, node* u = root) {
  if (u->index == k) {
    return -1e9;
  }
  if (i == n || j == m) {
    return 0;
  }
  int& ret = dp[i][j][u->index];
  if (~ret) {
    return ret;
  }
  ret = max({calc(i + 1, j, u), calc(i, j + 1, u), calc(i + 1, j + 1, u)});
  if (s[i] == w[j]) {
    ret = max(ret, calc(i + 1, j + 1, go(u, s[i])) + 1);
  }
  return ret;
}
void display(int i = 0, int j = 0, node* u = root) {
  if (i == n || j == m) {
    return;
  }
  int ret = calc(i, j, u);
  if (ret == calc(i + 1, j, u)) {
    return display(i + 1, j, u);
  }
  if (ret == calc(i, j + 1, u)) {
    return display(i, j + 1, u);
  }
  if (ret == calc(i + 1, j + 1, u)) {
    return display(i + 1, j + 1, u);
  }
  cout << s[i];
  display(i + 1, j + 1, go(u, s[i]));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> s >> w >> vi;
  n = s.size(), m = w.size(), k = vi.size();
  dp.resize(n, vector<vector<int>>(m, vector<int>(k, -1)));
  node* cur = root;
  for (int i = 0; i < k; ++i) {
    cur->next = new node(i + 1, vi[i]);
    cur->next->fail = go(cur->fail, vi[i]);
    cur = cur->next;
  }
  if (!calc()) {
    cout << 0;
  } else {
    display();
  }
  return 0;
}