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 spf[100001];
long long gcd(long long a, long long b);
long long palindrome(string s);
long long modexp(long long a, long long b, long long m);
void sieve();
long long ceil(long long a, long long b);
vector<long long> getFactorization(long long x);
void getZarr(string str, long long Z[]);
vector<long long> prefix_function(string s);
vector<long long> pi;
string s1, s2, virus;
long long dp[105][105][105];
long long prefix(long long j, string s, char ch) {
  while (j > 0 && ch != s[j]) {
    j = pi[j - 1];
  }
  if (ch == s[j]) {
    j++;
  }
  return j;
}
long long f(long long i, long long j, long long k) {
  if (dp[i][j][k] != -1) {
    return dp[i][j][k];
  }
  if (k == virus.length()) {
    return dp[i][j][k] = -1;
  }
  if (i == s1.length() || j == s2.length()) {
    return dp[i][j][k] = 0;
  } else if (s1[i] != s2[j]) {
    return dp[i][j][k] = max(f(i + 1, j, k), f(i, j + 1, k));
  } else {
    long long a = prefix(k, virus, s1[i]);
    if (a < k) {
      return dp[i][j][k] = 1 + f(i + 1, j + 1, a);
    } else
      return dp[i][j][k] = max(1 + f(i + 1, j + 1, a), f(i + 1, j + 1, k));
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s1 >> s2 >> virus;
  pi = prefix_function(virus);
  for (long long i = 0; i < 105; i++) {
    for (long long j = 0; j < 105; j++) {
      for (long long k = 0; k < 105; k++) {
        dp[i][j][k] = -1;
      }
    }
  }
  f(0, 0, 0);
  vector<char> v;
  long long i = 0, j = 0, k = 0;
  ;
  while (i < s1.length() && j < s2.length()) {
    if (s1[i] == s2[j]) {
      long long a = prefix(k, virus, s1[i]);
      if (dp[i + 1][j + 1][a] >= dp[i + 1][j + 1][k]) {
        v.push_back(s1[i]);
        k = a;
      }
      i++, j++;
    } else {
      if (dp[i + 1][j][k] > dp[i][j + 1][k]) {
        i++;
      } else
        j++;
    }
  }
  if (v.size() == 0)
    cout << 0 << '\n';
  else {
    for (auto x : v) {
      cout << x;
    }
    cout << '\n';
  }
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (a == b) return a;
  if (a > b) return gcd(a % b, b);
  return gcd(a, b % a);
}
long long palindrome(string s) {
  long long l = 0;
  long long h = s.length() - 1;
  while (h > l) {
    if (s[l++] != s[h--]) {
      return 0;
    }
  }
  return 1;
}
long long modexp(long long a, long long b, long long m) {
  if (b == 0) return 1;
  long long temp = modexp(a, b / 2, m);
  temp = (temp * temp) % m;
  if (b & 1) return (temp * (a % m)) % m;
  return temp;
}
void sieve() {
  spf[1] = 1;
  for (long long i = 2; i < 100001; i++) spf[i] = i;
  for (long long i = 4; i < 100001; i += 2) spf[i] = 2;
  for (long long i = 3; i * i < 100001; i++) {
    if (spf[i] == i) {
      for (long long j = i * i; j < 100001; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
vector<long long> getFactorization(long long x) {
  vector<long long> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
long long ceil(long long a, long long b) { return a / b + (a % b != 0); }
void getZarr(string str, long long Z[]) {
  long long n = str.length();
  long long L, R, k;
  L = R = 0;
  for (long long i = 1; i < n; ++i) {
    if (i > R) {
      L = R = i;
      while (R < n && str[R - L] == str[R]) R++;
      Z[i] = R - L;
      R--;
    } else {
      k = i - L;
      if (Z[k] < R - i + 1)
        Z[i] = Z[k];
      else {
        L = i;
        while (R < n && str[R - L] == str[R]) R++;
        Z[i] = R - L;
        R--;
      }
    }
  }
}
vector<long long> prefix_function(string s) {
  long long n = (long long)s.length();
  vector<long long> pi(n);
  for (long long i = 1; i < n; i++) {
    long long j = pi[i - 1];
    while (j > 0 && s[i] != s[j]) j = pi[j - 1];
    if (s[i] == s[j]) j++;
    pi[i] = j;
  }
  return pi;
}