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>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int MAXN = 1e2 + 10;
const string UV = "-1";
string dp[2][MAXN][MAXN];
int trans[MAXN][26];
string maxx(const string &a, const string &b) {
  if (a == UV) return b;
  if (b == UV) return a;
  if (a.size() > b.size()) return a;
  return b;
}
int main() {
  string a, b, v;
  cin >> a >> b >> v;
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < 26; j++) {
      int p = 0;
      string sub = v.substr(0, i) + (char)('A' + j);
      for (int k = 0, l = i + 1; k <= i; k++, l--)
        if (sub.substr(k, l) == v.substr(0, l)) {
          p = l;
          break;
        }
      trans[i][j] = p;
    }
  }
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < v.size(); k++) {
        if ((i == 0 || j == 0) && k == 0)
          dp[i][j][k] = "";
        else
          dp[i][j][k] = UV;
      }
  auto nxt = dp[1], pre = dp[0];
  for (int i = 1; i <= a.size(); i++) {
    for (int j = 1; j <= b.size(); j++)
      for (int k = 0; k < v.size(); k++) {
        nxt[j][k] = UV;
        if (a[i - 1] == b[j - 1])
          for (int x = 0; x < v.size(); x++)
            if (trans[x][a[i - 1] - 'A'] == k && pre[j - 1][x] != UV)
              nxt[j][k] = maxx(nxt[j][k], pre[j - 1][x] + a[i - 1]);
        nxt[j][k] = maxx(nxt[j][k], pre[j][k]);
        nxt[j][k] = maxx(nxt[j][k], nxt[j - 1][k]);
      }
    swap(nxt, pre);
  }
  string ans;
  for (int k = 0; k < v.size(); k++) ans = maxx(ans, pre[b.size()][k]);
  if (ans.size() == 0)
    cout << 0 << endl;
  else
    cout << ans << endl;
  return 0;
}