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 = 105;
int fail[N];
string s;
int n;
void buildFailureFunction() {
  n = s.size();
  fail[0] = fail[1] = 0;
  for (int i = 2; i <= n; i++) {
    fail[i] = (s[i - 1] == s[0]);
    for (int j = fail[i - 1]; j > 0; j = fail[j])
      if (s[j] == s[i - 1]) {
        fail[i] = j + 1;
        break;
      }
  }
}
const int K = 26;
int f[N][K];
void calc() {
  for (int i = 0; i <= n; i++) {
    if (i < n) f[i][s[i] - 'A'] = i + 1;
    int cur = i;
    while (cur != 0) {
      cur = fail[cur];
      if (f[i][s[cur] - 'A'] == 0) f[i][s[cur] - 'A'] = cur + 1;
    }
  }
}
int dp[N][N][N];
int pre[N][N][N];
int main() {
  memset(pre, -1, sizeof pre);
  string a, b;
  cin >> a >> b >> s;
  buildFailureFunction();
  calc();
  int n = a.size();
  int m = b.size();
  int kk = s.size();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int k = 0; k < kk; k++) {
        dp[i][j][k] = max(dp[i][j - 1][k], dp[i - 1][j][k]);
        if (a[i - 1] == b[j - 1]) {
          char c = a[i - 1] - 'A';
          for (int l = 0; l < kk; l++)
            if (f[l][c] == k) {
              int cur = 1 + dp[i - 1][j - 1][l];
              if (dp[i][j][k] < cur) {
                dp[i][j][k] = cur;
                pre[i][j][k] = l;
              }
            }
        }
      }
  int cx = n, cy = m, cz = 0;
  for (int k = 0; k < kk; k++)
    if (dp[n][m][cz] < dp[n][m][k]) cz = k;
  string ans;
  while (cx && cy) {
    if (pre[cx][cy][cz] >= 0) {
      ans += a[cx - 1];
      cz = pre[cx--][cy--][cz];
    } else {
      if (dp[cx][cy - 1][cz] > dp[cx - 1][cy][cz])
        cy--;
      else
        cx--;
    }
  }
  reverse(ans.begin(), ans.end());
  if (ans == "") ans = "0";
  cout << ans << endl;
}