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 long long int M = 100 + 5, SM = 600;
const long long int inf = 1e18;
const long long int lg = 18;
const long long int z = 26;
long long int dp[M][M][M];
string dps[M][M][M];
long long int x;
long long int nxt[M][z];
long long int tt = 1;
long long int f[M];
long long int insert(string s) {
  long long int p = 0;
  for (char c : s) {
    if (nxt[p][c - 'A'] == 0) {
      nxt[p][c - 'A'] = tt++;
    }
    p = nxt[p][c - 'A'];
  }
  return p;
}
int main() {
  string s, t, virus;
  cin >> s >> t;
  long long int n = ((long long int)s.size());
  long long int m = ((long long int)t.size());
  cin >> virus;
  long long int vi = insert(virus);
  {
    queue<long long int> q;
    for (long long int i = 0; i < 26; i++) {
      if (nxt[0][i] != 0) q.push(nxt[0][i]);
    }
    while (((long long int)q.size()) > 0) {
      long long int x = q.front();
      q.pop();
      for (long long 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]);
        }
      }
    }
  }
  for (long long int i = 1; i < n + 1; i++) {
    for (long long int j = 1; j < m + 1; j++) {
      if (s[i - 1] == t[j - 1]) {
        for (long long int k = 0; k < tt; k++) {
          long long int d = nxt[k][s[i - 1] - 'A'];
          if (k == vi || d == vi) continue;
          if (dp[i][j][d] < dp[i - 1][j - 1][k] + 1) {
            dp[i][j][d] = dp[i - 1][j - 1][k] + 1;
            dps[i][j][d] = dps[i - 1][j - 1][k] + s[i - 1];
          }
        }
      }
      for (long long int k = 0; k < tt; k++) {
        if (dp[i][j][k] < dp[i][j - 1][k]) {
          dp[i][j][k] = dp[i][j - 1][k];
          dps[i][j][k] = dps[i][j - 1][k];
        }
        if (dp[i][j][k] < dp[i - 1][j][k]) {
          dp[i][j][k] = dp[i - 1][j][k];
          dps[i][j][k] = dps[i - 1][j][k];
        }
      }
    }
  }
  long long int res = 0;
  string pes = "";
  for (long long int k = 0; k < tt; k++) {
    if (k != vi) {
      if (res < dp[n][m][k]) {
        res = dp[n][m][k];
        pes = dps[n][m][k];
      }
    }
  }
  cout << (pes == "" ? "0" : pes);
}