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;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = ((ans % m) * (a % m)) % m;
    b /= 2;
    a = ((a % m) * (a % m)) % m;
  }
  return ans % m;
}
string s1, s2, virus;
int dp[101][101][101];
int b[101];
void lps() {
  int i = 0, j = -1;
  b[0] = -1;
  int m = virus.length();
  while (i < m) {
    while (j >= 0 && virus[i] != virus[j]) j = b[j];
    i++;
    j++;
    b[i] = j;
  }
}
int solve(int id1, int id2, int len) {
  if (len == virus.length()) {
    return -(long long)1e6 + 2;
  }
  if (id1 == s1.length()) return 0;
  if (id2 == s2.length()) return 0;
  if (dp[id1][id2][len] != -1) return dp[id1][id2][len];
  int ans = -(long long)1e6 + 2;
  ans = max(ans, solve(id1 + 1, id2 + 1, len));
  if (s1[id1] == s2[id2]) {
    if (s1[id1] == virus[len])
      ans = max(ans, 1 + solve(id1 + 1, id2 + 1, len + 1));
    else {
      int j = len;
      while (j >= 0 && s1[id1] != virus[j]) j = b[j];
      ans = max(ans, 1 + solve(id1 + 1, id2 + 1, j + 1));
    }
  } else {
    ans = max(ans, solve(id1 + 1, id2, len));
    ans = max(ans, solve(id1, id2 + 1, len));
  }
  return dp[id1][id2][len] = ans;
}
void print(int id1, int id2, int len) {
  if (len == virus.length()) return;
  if (id1 == s1.length() || id2 == s2.length()) return;
  if (dp[id1][id2][len] == solve(id1 + 1, id2 + 1, len)) {
    print(id1 + 1, id2 + 1, len);
    return;
  }
  if (s1[id1] == s2[id2]) {
    if (s1[id1] == virus[len]) {
      if (dp[id1][id2][len] == 1 + solve(id1 + 1, id2 + 1, len + 1)) {
        cout << s1[id1];
        print(id1 + 1, id2 + 1, len + 1);
      }
    } else {
      int j = len;
      while (j >= 0 && s1[id1] != virus[j]) j = b[j];
      if (dp[id1][id2][len] == 1 + solve(id1 + 1, id2 + 1, j + 1)) {
        cout << s1[id1];
        print(id1 + 1, id2 + 1, j + 1);
      }
    }
  } else {
    if (dp[id1][id2][len] == solve(id1 + 1, id2, len))
      print(id1 + 1, id2, len);
    else if (dp[id1][id2][len] == solve(id1, id2 + 1, len))
      print(id1, id2 + 1, len);
  }
}
int main() {
  cin >> s1 >> s2 >> virus;
  memset(dp, -1, sizeof dp);
  lps();
  int ans = solve(0, 0, 0);
  if (ans < 0) ans = 0;
  if (ans == 0) {
    cout << 0;
    return 0;
  }
  print(0, 0, 0);
}