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 N = 1e2 + 10;
int dp[N][N][N];
int to[N][N][N];
int cnt = 1;
int go[N][26];
bool leaf[N];
void push(string &s) {
  int cur = 0;
  for (auto c : s) {
    int idx = c - 'A';
    if (!go[cur][idx]) go[cur][idx] = cnt++;
    cur = go[cur][idx];
  }
  leaf[cur] = 1;
}
void make() {
  queue<pair<int, int> > Q;
  for (int i = 0; i < 26; i++)
    if (go[0][i]) Q.push({go[0][i], 0});
  while (!Q.empty()) {
    auto cur = Q.front();
    Q.pop();
    int u = cur.first, f = cur.second;
    leaf[u] |= leaf[f];
    for (int i = 0; i < 26; i++) {
      if (go[u][i])
        Q.push({go[u][i], go[f][i]});
      else
        go[u][i] = go[f][i];
    }
  }
}
int n, m;
string s1, s2, s3;
int f(int i, int j, int k) {
  if (i > n || j > m) return 0;
  int &ans = dp[i][j][k];
  if (ans != -1) return ans;
  ans = f(i + 1, j, k);
  to[i][j][k] = 1;
  if (ans < f(i, j + 1, k)) {
    ans = f(i, j + 1, k);
    to[i][j][k] = 2;
  }
  if (s1[i - 1] == s2[j - 1]) {
    int nxt = go[k][s1[i - 1] - 'A'];
    if (!leaf[nxt] && ans < f(i + 1, j + 1, nxt) + 1) {
      ans = f(i + 1, j + 1, nxt) + 1;
      to[i][j][k] = 3;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s1 >> s2 >> s3;
  n = s1.length();
  m = s2.length();
  memset(dp, -1, sizeof dp);
  push(s3);
  make();
  int ans = f(1, 1, 0);
  if (ans == 0) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1, j = 1, k = 0; i <= n && j <= m;) {
    if (to[i][j][k] == 1)
      i++;
    else if (to[i][j][k] == 2)
      j++;
    else {
      cout << s1[i - 1];
      k = go[k][s1[i - 1] - 'A'];
      i++;
      j++;
    }
  }
  cout << endl;
  return 0;
}