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 gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long powm(long long base, long long exp, long long mod = 998244353) {
  base %= mod;
  long long ans = 1;
  while (exp) {
    if (exp & 1LL) ans = (ans * base) % mod;
    exp >>= 1LL, base = (base * base) % mod;
  }
  return ans;
}
int dp[101][101][101];
string a[101][101][101];
vector<long long> prefix_function(string s) {
  vector<long long> f(s.size());
  f[0] = 0;
  for (long long i = 1; i < s.size(); i++) {
    long long j = f[i - 1];
    while (j > 0 && s[i] != s[j]) {
      j = f[j - 1];
    }
    if (s[i] == s[j]) j++;
    f[i] = j;
  }
  return f;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s1, s2, v;
  cin >> s1 >> s2 >> v;
  vector<long long> f = prefix_function(v);
  for (int i = 0; i < s1.length(); i++) {
    for (int j = 0; j < s2.length(); j++) {
      if (i == 0 && j == 0) {
        if (s1[0] == s2[0]) {
          if (s1[0] != v[0]) {
            dp[i][j][0] = 1;
            a[i][j][0] = s1[0];
          } else {
            dp[i][j][1] = 1;
            a[i][j][1] = s1[0];
          }
        }
        continue;
      }
      if (i == 0) {
        for (int k = 0; k <= v.length(); k++) {
          dp[i][j][k] = dp[i][j - 1][k];
          a[i][j][k] = a[i][j - 1][k];
        }
        if (s1[i] == s2[j]) {
          if (s1[i] == v[0]) {
            dp[i][j][1] = 1;
            a[i][j][1] = s1[i];
          } else {
            dp[i][j][0] = 1;
            a[i][j][0] = s1[i];
          }
        }
        continue;
      }
      if (j == 0) {
        for (int k = 0; k <= v.length(); k++) {
          dp[i][j][k] = dp[i - 1][j][k];
          a[i][j][k] = a[i - 1][j][k];
        }
        if (s1[i] == s2[j]) {
          if (s1[i] == v[0]) {
            dp[i][j][1] = 1;
            a[i][j][1] = s1[i];
          } else {
            dp[i][j][0] = 1;
            a[i][j][0] = s1[i];
          }
        }
        continue;
      }
      for (int k = 0; k <= v.length(); k++) {
        if (dp[i - 1][j][k] > dp[i][j - 1][k]) {
          dp[i][j][k] = dp[i - 1][j][k];
          a[i][j][k] = a[i - 1][j][k];
        } else {
          dp[i][j][k] = dp[i][j - 1][k];
          a[i][j][k] = a[i][j - 1][k];
        }
      }
      if (s1[i] == s2[j]) {
        for (int k = 1; k < v.length(); k++) {
          if (dp[i - 1][j - 1][k] == 0) continue;
          if (k == v.length() - 1 && v[k] == s1[i]) continue;
          int p = f[k - 1];
          while (p > 0 && s1[i] != v[p]) {
            p = f[p - 1];
          }
          if (s1[i] == v[p]) p++;
          if (v[k] == s1[i]) {
            p = k + 1;
          }
          if (dp[i][j][p] < dp[i - 1][j - 1][k] + 1) {
            dp[i][j][p] = dp[i - 1][j - 1][k] + 1;
            a[i][j][p] = a[i - 1][j - 1][k] + s1[i];
          }
        }
        if (v[0] == s1[i]) {
          if (dp[i][j][1] < dp[i - 1][j - 1][0] + 1) {
            dp[i][j][1] = dp[i - 1][j - 1][0] + 1;
            a[i][j][1] = a[i - 1][j - 1][0] + s1[i];
          }
        } else {
          if (dp[i][j][0] < dp[i - 1][j - 1][0] + 1) {
            dp[i][j][0] = dp[i - 1][j - 1][0] + 1;
            a[i][j][0] = a[i - 1][j - 1][0] + s1[i];
          }
        }
      }
    }
  }
  string ans = "";
  int temp = 0;
  for (int i = 0; i < v.length(); i++) {
    if (temp < dp[s1.length() - 1][s2.length() - 1][i]) {
      ans = a[s1.length() - 1][s2.length() - 1][i];
      temp = dp[s1.length() - 1][s2.length() - 1][i];
    }
  }
  if (ans == "")
    cout << 0 << '\n';
  else
    cout << ans << '\n';
}