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;
const int N = 2e2 + 5;
string s, t, virus, ans = "";
pair<long long int, string> dp[110][110][110], u = make_pair(-1e9, "");
int vir = 0, m = 0, cnt = 1, f[400], x, y, pos = 0, nxt[4000][30];
queue<int> q;
void str(string s1) {
  pos = 0;
  char c;
  for (int i = 0; i < s1.size(); i++) {
    c = s1[i];
    if (nxt[pos][c - 'A'] == 0) nxt[pos][c - 'A'] = cnt++;
    pos = nxt[pos][c - 'A'];
  }
  vir = pos;
}
void aho() {
  for (int i = 0; i < 26; i++) {
    if (nxt[0][i] != 0) q.push(nxt[0][i]);
  }
  while (!q.empty()) {
    x = q.front(), q.pop();
    for (int i = 0; i < 26; i++) {
      if (nxt[x][i] == 0)
        nxt[x][i] = nxt[f[x]][i];
      else {
        f[nxt[x][i]] = nxt[f[x]][i];
        q.push(nxt[x][i]);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> s;
  cin >> t;
  cin >> virus;
  str(virus);
  aho();
  pos = 0;
  for (int i = 1; i <= s.size(); i++) {
    for (int j = 1; j <= t.size(); j++) {
      if (s[i - 1] == t[j - 1])
        for (int k = 0; k < cnt; k++) {
          if (k == vir || nxt[k][s[i - 1] - 'A'] == vir) continue;
          if (dp[i][j][nxt[k][s[i - 1] - 'A']].first <
              dp[i - 1][j - 1][k].first + 1) {
            dp[i][j][nxt[k][s[i - 1] - 'A']].first =
                dp[i - 1][j - 1][k].first + 1;
            dp[i][j][nxt[k][s[i - 1] - 'A']].second =
                dp[i - 1][j - 1][k].second + s[i - 1];
          }
        }
      for (int k = 0; k < cnt; k++) {
        if (k == vir) continue;
        if (dp[i][j][k].first < dp[i][j - 1][k].first)
          dp[i][j][k] = dp[i][j - 1][k];
        if (dp[i][j][k].first < dp[i - 1][j][k].first)
          dp[i][j][k] = dp[i - 1][j][k];
      }
    }
  }
  for (int i = 0; i < cnt; i++) {
    if (i != vir) u = max(u, dp[s.size()][t.size()][i]);
  }
  if (u.first == 0)
    cout << 0;
  else
    cout << u.second;
  return 0;
}