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 GCC optimize("O2")
using namespace std;
inline long long input() {
  long long n;
  cin >> n;
  return n;
}
long long poww(long long a, long long b, long long md) {
  return (!b ? 1
             : (b & 1 ? a * poww(a * a % md, b / 2, md) % md
                      : poww(a * a % md, b / 2, md) % md));
}
const int MAXN = 100 + 10;
const int MAXLG = 18;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const long long INF = 8e18;
long long dp[MAXN][MAXN][MAXN];
long long ps[MAXN][MAXN][MAXN];
string str[MAXN][MAXN][MAXN];
string s1, s2, virus;
long long f[MAXN][26];
long long pi[MAXN];
long long ans;
string res;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> s1 >> s2 >> virus;
  for (int i = 1; i < virus.size(); i++) {
    long long j = pi[i - 1];
    while (j and virus[j] != virus[i]) j = pi[j - 1];
    if (virus[i] == virus[j]) j++;
    pi[i] = j;
  }
  for (int i = 0; i < virus.size(); i++) {
    for (int c = 0; c < 26; c++) {
      if (i and c != virus[i] - 'A') {
        f[i][c] = f[pi[i - 1]][c];
      } else {
        f[i][c] = i + (c == virus[i] - 'A');
      }
    }
  }
  s1 = "#" + s1;
  s2 = "#" + s2;
  for (int i = 1; i < s1.size(); i++) {
    for (int j = 1; j < s2.size(); j++) {
      for (int k = 0; k < virus.size(); k++) {
        ps[i][j][k] = ps[i - 1][j - 1][k];
        str[i][j][k] = str[i - 1][j - 1][k];
        ps[i][j][k] = max(ps[i][j][k], ps[i - 1][j][k]);
        if (ps[i][j][k] == ps[i - 1][j][k]) str[i][j][k] = str[i - 1][j][k];
        ps[i][j][k] = max(ps[i][j][k], ps[i][j - 1][k]);
        if (ps[i][j][k] == ps[i][j - 1][k]) str[i][j][k] = str[i][j - 1][k];
        if (s1[i] != s2[j]) continue;
        string tmp;
        for (int l = 0; l < virus.size(); l++) {
          long long x = f[l][s1[i] - 'A'];
          if (x == virus.size()) continue;
          if (x == k) {
            dp[i][j][k] = max(dp[i][j][k], ps[i - 1][j - 1][l] + 1);
            if (dp[i][j][k] == ps[i - 1][j - 1][l] + 1)
              tmp = str[i - 1][j - 1][l] + s1[i];
          }
        }
        ps[i][j][k] = max(dp[i][j][k], ps[i][j][k]);
        if (ps[i][j][k] == dp[i][j][k]) str[i][j][k] = tmp;
      }
    }
  }
  for (int i = 0; i < virus.size(); i++) {
    if (ps[s1.size() - 1][s2.size() - 1][i] > ans) {
      ans = ps[s1.size() - 1][s2.size() - 1][i];
      res = str[s1.size() - 1][s2.size() - 1][i];
    }
  }
  if (ans == 0) {
    cout << 0 << "\n";
    return 0;
  }
  cout << res << "\n";
}