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;
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;
}
const long long N = 105;
long long dp[N][N][N][2];
string s1, s2, s3;
long long x, y, z;
string s = "";
vector<long long> pi;
long long solve(long long l1, long long l2, long long l3, long long run) {
  if (l3 == z) {
    return -1e5;
  }
  if (l1 == x or l2 == y) {
    return 0;
  }
  long long &ans = dp[l1][l2][l3][run];
  if (ans != -1) {
    return ans;
  }
  ans = 0;
  if (!run) {
    ans = max(solve(l1 + 1, l2, l3, 0), solve(l1, l2 + 1, l3, 0));
  }
  if (s1[l1] == s2[l2]) {
    if (s1[l1] == s3[l3]) {
      ans = max(ans, 1 + solve(l1 + 1, l2 + 1, l3 + 1, 0));
    } else {
      if (l3 == 0) {
        ans = max(ans, 1 + solve(l1 + 1, l2 + 1, l3, 0));
      } else {
        ans = max(ans, solve(l1, l2, pi[l3 - 1], 1));
      }
    }
  }
  return ans;
}
void make(long long l1, long long l2, long long l3, long long run) {
  if (l1 == x or l2 == y) {
    return;
  }
  long long ans = solve(l1, l2, l3, run);
  if (ans <= 0) {
    return;
  }
  if (!run and solve(l1 + 1, l2, l3, run) == ans) {
    return make(l1 + 1, l2, l3, run);
  }
  if (!run and solve(l1, l2 + 1, l3, run) == ans) {
    return make(l1, l2 + 1, l3, run);
  }
  if (s1[l1] == s2[l2]) {
    if (s1[l1] == s3[l3]) {
      s += s1[l1];
      return make(l1 + 1, l2 + 1, l3 + 1, 0);
    } else {
      if (l3 == 0) {
        s += s1[l1];
        return make(l1 + 1, l2 + 1, l3, 0);
      } else {
        return make(l1, l2, pi[l3 - 1], 1);
      }
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> s1 >> s2 >> s3;
  x = s1.length();
  y = s2.length();
  z = s3.length();
  pi = prefix_function(s3);
  memset(dp, -1, sizeof(dp));
  long long len = solve(0, 0, 0, 0);
  if (len == 0) {
    cout << 0 << endl;
  } else {
    make(0, 0, 0, 0);
    cout << s << endl;
  }
  return 0;
}