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;
#pragma GCC optimize("03")
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return b / gcd(a, b) * a; }
const int dx[] = {1, -1, 0, 0, -1, 1, -1, 1};
const int dy[] = {0, 0, -1, 1, 1, 1, -1, -1};
const int kx[] = {-2, -1, 1, 2, 2, 1, -1, -2};
const int ky[] = {1, 2, 2, 1, -1, -2, -2, -1};
const int mx = 1e2 + 5;
const double eps = 1e-9;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
string s, t, v;
int pos[mx][mx];
int dp[mx][mx][mx];
void calc() {
  for (int i = 0; i < v.size(); i++)
    for (char c = 'A'; c <= 'Z'; c++) {
      string ss = v.substr(0, i) + c;
      for (int k = 0; k <= i + 1; k++)
        if (v.substr(0, k) == ss.substr(i - k + 1, k)) pos[i][c] = k;
    }
}
int fun1(int i, int j, int k) {
  if (k == v.size()) return -inf;
  if (i == s.size() || j == t.size()) return 0;
  int &ans = dp[i][j][k];
  if (~ans) return ans;
  ans = max(fun1(i + 1, j, k), fun1(i, j + 1, k));
  if (s[i] == t[j]) ans = max(ans, 1 + fun1(i + 1, j + 1, pos[k][s[i]]));
  return ans;
}
void fun2(int i, int j, int k) {
  if (k == v.size()) return;
  if (i == s.size() || j == t.size()) return;
  int &ans = dp[i][j][k];
  if (ans == fun1(i + 1, j, k))
    fun2(i + 1, j, k);
  else if (ans == fun1(i, j + 1, k))
    fun2(i, j + 1, k);
  else if (s[i] == t[j] && ans == 1 + fun1(i + 1, j + 1, pos[k][s[i]])) {
    cout << s[i];
    fun2(i + 1, j + 1, pos[k][s[i]]);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cin >> s >> t >> v;
  calc();
  memset(dp, -1, sizeof dp);
  if (fun1(0, 0, 0))
    fun2(0, 0, 0);
  else
    cout << "0";
  cout << "\n";
  return 0;
}