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 fail[122];
int dp[122][122][122];
struct {
  int x, y, z;
} cf[122][122][122];
int main() {
  string s, t, u;
  cin >> s >> t >> u;
  int n = s.size(), m = t.size(), k = u.size();
  s = "$" + s + "@";
  t = "#" + t + "@";
  u = "*" + u + "*";
  [&](string &s) {
    fail[1] = 0;
    for (int i = 2; i <= k; ++i) {
      int j = i - 1;
      while (j > 1 && s[fail[j] + 1] != s[i]) j = fail[j];
      fail[i] = (s[fail[j] + 1] == s[i] ? fail[j] + 1 : fail[j]);
    }
  }(u);
  memset(dp, 0xa0, sizeof(dp));
  dp[0][0][0] = 0;
  auto up = [&](int v, int di, int dj, int dk, int si, int sj, int sk) {
    if (v >= dp[di][dj][dk]) {
      dp[di][dj][dk] = v;
      cf[di][dj][dk] = {si, sj, sk};
    }
  };
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) {
      for (int z = 0; z < k; ++z) {
        if (s[i + 1] == t[j + 1]) {
          if (s[i + 1] == u[z + 1]) {
            up(dp[i][j][z] + 1, i + 1, j + 1, z + 1, i, j, z);
          } else {
            int t = fail[z];
            while (t >= 1 && s[i + 1] != u[t + 1]) t = fail[t];
            int to = t + (s[i + 1] == u[t + 1]);
            up(dp[i][j][z] + 1, i + 1, j + 1, to, i, j, z);
          }
        }
        up(dp[i][j][z], i, j + 1, z, i, j, z);
        up(dp[i][j][z], i + 1, j, z, i, j, z);
      }
    }
  }
  int mx = -1, mxk = -1;
  for (int z = 0; z < k; ++z) {
    if (dp[n][m][z] > mx) {
      mx = dp[n][m][z];
      mxk = z;
    }
  }
  if (mx <= 0) exit((cout << 0 << endl, 0));
  int i = n, j = m, z = mxk;
  stack<char> ans;
  while (i && j) {
    if (cf[i][j][z].x != i && cf[i][j][z].y != j) ans.push(s[i]);
    tie(i, j, z) = make_tuple(cf[i][j][z].x, cf[i][j][z].y, cf[i][j][z].z);
  }
  while (ans.size()) {
    cout << ans.top();
    ans.pop();
  }
}