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;
int memo[101][101][101], pi_match[26][101];
string x, y, z;
int n, m, l;
struct KMP {
  int sz;
  string s;
  vector<int> pi;
  void init(string x) {
    s = x;
    sz = s.size();
    pi.resize(sz);
    compute();
  }
  void compute() {
    for (int i = 1; i < sz; i++) {
      int j = pi[i - 1];
      while (j > 0 && s[i] != s[j]) j = pi[j - 1];
      if (s[i] == s[j]) j++;
      pi[i] = j;
    }
  }
  int get(int j, char c) {
    while (j > 0 && c != s[j]) j = pi[j - 1];
    if (c == s[j]) j++;
    return j;
  }
} kmp;
int dp(int i, int j, int k) {
  if (k == l) return -1e9;
  if (i == n || j == m) return 0;
  if (memo[i][j][k] != -1) return memo[i][j][k];
  if (x[i] != y[j])
    return memo[i][j][k] = max(dp(i + 1, j, k), dp(i, j + 1, k));
  else {
    int res1 = 1 + dp(i + 1, j + 1, pi_match[x[i] - 'A'][k]);
    int res2 = dp(i + 1, j, k);
    int res3 = dp(i, j + 1, k);
    return memo[i][j][k] = max({res1, res2, res3});
  }
}
void build(int i, int j, int k) {
  if (k == l) return;
  if (i == n || j == m) return;
  int res1 = dp(i + 1, j, k);
  int res2 = dp(i, j + 1, k);
  if (x[i] != y[j]) {
    if (res1 > res2)
      build(i + 1, j, k);
    else
      build(i, j + 1, k);
  } else {
    int res = 1 + dp(i + 1, j + 1, pi_match[x[i] - 'A'][k]);
    int mx = max({res, res1, res2});
    if (mx == res) {
      cout << x[i];
      build(i + 1, j + 1, pi_match[x[i] - 'A'][k]);
    } else if (mx == res1)
      build(i + 1, j, k);
    else
      build(i, j + 1, k);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> x >> y >> z;
  kmp.init(z);
  n = x.size(), m = y.size(), l = z.size();
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      for (int k = 0; k <= l; k++) {
        memo[i][j][k] = -1;
      }
    }
  }
  for (char c = 'A'; c <= 'Z'; c++) {
    for (int i = 0; i < l; i++) {
      pi_match[c - 'A'][i] = kmp.get(i, c);
    }
  }
  int res = dp(0, 0, 0);
  if (!res)
    cout << 0 << "\n";
  else
    build(0, 0, 0);
  return 0;
}