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 = 100 + 5;
const int M = 1e6 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;
int aut[N][26], dp[N][N][N], pi[N];
string s1, s2, s3;
int solve(int i1, int i2, int i3) {
  if (i3 == s3.size()) return -OO;
  if (i1 == s1.size() || i2 == s2.size()) return 0;
  auto &ret = dp[i1][i2][i3];
  if (~ret) return ret;
  ret = max(solve(i1 + 1, i2, i3), solve(i1, i2 + 1, i3));
  if (s1[i1] == s2[i2]) {
    ret = max(ret, 1 + solve(i1 + 1, i2 + 1, aut[i3][s1[i1] - 'A']));
  }
  return ret;
}
void build(int i1, int i2, int i3) {
  if (i1 == s1.size() || i2 == s2.size()) return;
  auto &ret = dp[i1][i2][i3];
  if (ret == solve(i1 + 1, i2, i3)) {
    build(i1 + 1, i2, i3);
    return;
  }
  if (ret == solve(i1, i2 + 1, i3)) {
    build(i1, i2 + 1, i3);
    return;
  }
  cout << s1[i1];
  build(i1 + 1, i2 + 1, aut[i3][s1[i1] - 'A']);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> s1 >> s2 >> s3;
  memset(dp, -1, sizeof dp);
  pi[0] = 0;
  for (int i = 1; i < s3.size(); ++i) {
    int &j = pi[i];
    j = pi[i - 1];
    while (j > 0 && s3[i] != s3[j]) {
      j = pi[j - 1];
    }
    if (s3[i] == s3[j]) ++j;
  }
  for (int i = 0; i < s3.size(); ++i) {
    for (int c = 0; c < 26; ++c) {
      aut[i][c] = i > 0 && s3[i] != c + 'A' ? aut[pi[i - 1]][c]
                                            : i + (s3[i] == c + 'A');
    }
  }
  auto ans = solve(0, 0, 0);
  if (ans) {
    build(0, 0, 0);
  } else {
    cout << "0\n";
  }
  return 0;
}