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;
long long int dp[105][105][105];
long long int opti[105][105][105];
long long int lps[105];
string s, s1, s2, ans;
long long int n, m, o;
long long int rec(long long int i, long long int j, long long int k) {
  if (k >= o) return -1e16;
  if (i >= n || j >= m) return 0;
  if (dp[i][j][k] != -1) return dp[i][j][k];
  long long int an = -1e16, x = 0;
  if (s[i] == s1[j]) {
    long long int y = k;
    if (s2[k] != s[i]) {
      y--;
      y = max(y, 0ll);
      y = lps[y];
      while (y > 0) {
        if (s2[y] == s[i]) {
          y++;
          break;
        }
        y = lps[y - 1];
      }
      if (y == 0 && s2[y] == s[i]) y++;
    } else
      y++;
    x = rec(i + 1, j + 1, y) + 1;
    if (x > an) {
      opti[i][j][k] = 1;
      an = x;
    }
  }
  x = rec(i + 1, j, k);
  if (x > an) {
    opti[i][j][k] = 2;
    an = x;
  }
  x = rec(i, j + 1, k);
  if (x > an) {
    opti[i][j][k] = 3;
    an = x;
  }
  return dp[i][j][k] = an;
}
void computeLPSArray() {
  int len = 0;
  lps[0] = 0;
  int i = 1;
  while (i < o) {
    if (s2[i] == s2[len]) {
      len++;
      lps[i] = len;
      i++;
    } else {
      if (len != 0) {
        len = lps[len - 1];
      } else {
        lps[i] = 0;
        i++;
      }
    }
  }
}
int main() {
  for (int i = 0; i <= 104; i++)
    for (int j = 0; j <= 104; j++)
      for (int k = 0; k <= 104; k++) {
        dp[i][j][k] = -1;
        opti[i][j][k] = -1;
      }
  cin >> s >> s1 >> s2;
  n = s.length();
  m = s1.length();
  o = s2.length();
  computeLPSArray();
  long long int an = rec(0, 0, 0);
  if (an <= 0) return cout << "0" << '\n', 0;
  long long int i = 0, j = 0, k = 0;
  ans = "";
  while (opti[i][j][k] != -1) {
    if (opti[i][j][k] == 1) {
      ans.push_back(s[i]);
      long long int y = k;
      if (s2[k] != s[i]) {
        y--;
        y = max(y, 0ll);
        y = lps[y];
        while (y > 0) {
          if (s2[y] == s[i]) {
            y++;
            break;
          }
          y = lps[y - 1];
        }
        if (y == 0 && s2[y] == s[i]) y++;
      } else
        y++;
      k = y;
      i++, j++;
    } else if (opti[i][j][k] == 2)
      i++;
    else
      j++;
  }
  cout << ans << '\n';
  return 0;
}