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;
string s, t, pp;
int b[105], len1, len2, len3, dp[105][105][105], pizza;
bool done[105][105][105];
inline void preprocess() {
  int i = 0, j = -1;
  b[i] = j;
  while (i < len3) {
    while (j >= 0 && pp.at(i) != pp.at(j)) j = b[j];
    j++, i++;
    b[i] = j;
  }
}
int f(int p, int q, int r) {
  if (r == len3) return -(1 << 30);
  ;
  if (p == len1 || q == len2) return 0;
  if (done[p][q][r]) {
    return dp[p][q][r];
  }
  done[p][q][r] = 1;
  int ans = max(f(p + 1, q, r), f(p, q + 1, r));
  if (s.at(p) == t.at(q)) {
    if (s.at(p) == pp.at(r)) {
      ans = max(ans, 1 + f(p + 1, q + 1, r + 1));
    } else {
      int rr = r;
      while (rr >= 0 && pp.at(rr) != s.at(p)) rr = b[rr];
      rr++;
      ans = max(ans, 1 + f(p + 1, q + 1, rr));
    }
  }
  return dp[p][q][r] = ans;
}
void print(int p, int q, int r) {
  if (p == len1 || q == len2 || r == len3) return;
  if (dp[p][q][r] == dp[p + 1][q][r]) {
    print(p + 1, q, r);
  } else if (dp[p][q][r] == dp[p][q + 1][r]) {
    print(p, q + 1, r);
  } else if (s.at(p) == t.at(q)) {
    if (s.at(p) == pp.at(r)) {
      printf("%c", s.at(p));
      print(p + 1, q + 1, r + 1);
    } else {
      printf("%c", s.at(p));
      int rr = r;
      while (rr >= 0 && pp.at(rr) != s.at(p)) rr = b[rr];
      rr++;
      print(p + 1, q + 1, rr);
    }
  }
  return;
}
int main() {
  cin >> s >> t >> pp;
  len3 = pp.length();
  len1 = s.length();
  len2 = t.length();
  preprocess();
  pizza = f(0, 0, 0);
  if (pizza) {
    print(0, 0, 0);
    printf("\n");
  } else {
    printf("0\n");
  }
  return 0;
}