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 pi[110], aut[110][26], len;
char s[110];
string A, B;
void init() {
  len = strlen(s);
  for (int i = 1; i < len; ++i) {
    int j = pi[i - 1];
    while (j > 0 and s[i] != s[j]) j = pi[j - 1];
    if (s[i] == s[j]) ++j;
    pi[i] = j;
  }
  for (int i = 0; i < len; ++i)
    for (int c = 0; c < 26; ++c) {
      int j = i;
      while (j > 0 and s[j] != char(c + 'A')) j = pi[j - 1];
      if (s[j] == char(c + 'A')) ++j;
      aut[i][c] = j;
    }
}
int DP[110][110][110];
int solve(int i, int j, int k) {
  int &res = DP[i][j][k];
  if (res != -1) return res;
  res = 0;
  if (i == A.size() or j == B.size()) return res;
  res = max(res, solve(i + 1, j, k));
  res = max(res, solve(i, j + 1, k));
  if (A[i] == B[j] and aut[k][A[i] - 'A'] != len)
    res = max(res, 1 + solve(i + 1, j + 1, aut[k][A[i] - 'A']));
  return res;
}
string findString(int i, int j, int k) {
  if (i == A.size() or j == B.size()) return string("");
  int a = solve(i + 1, j, k), b = solve(i, j + 1, k), c = -1;
  if (A[i] == B[j] and aut[k][A[i] - 'A'] != len)
    c = 1 + solve(i + 1, j + 1, aut[k][A[i] - 'A']);
  if (a >= b and a >= c) return findString(i + 1, j, k);
  if (b >= a and b >= c) return findString(i, j + 1, k);
  return A[i] + findString(i + 1, j + 1, aut[k][A[i] - 'A']);
}
int main() {
  cin >> A >> B >> s;
  init();
  memset(DP, -1, sizeof DP);
  int res = solve(0, 0, 0);
  if (res == 0)
    cout << 0;
  else
    cout << findString(0, 0, 0);
}