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>
enum { LEFT, RIGHT, BOTH };
const int INF = INT_MAX >> 1;
std::string virus, s1, s2;
std::vector<int> failure;
int solution[105][105][105];
bool solved[105][105][105];
int next[105][105][105];
void fill_failure(void) {
  int candidate, pos;
  failure.clear();
  failure.resize(virus.size());
  pos = 2;
  candidate = 0;
  failure[1] = 0;
  failure[0] = -1;
  while (pos < virus.size()) {
    if (virus[pos - 1] == virus[candidate]) {
      failure[pos++] = ++candidate;
    } else if (candidate > 0) {
      candidate = failure[candidate];
    } else {
      failure[pos++] = 0;
    }
  }
}
int longest_match(const int pos_s1, const int pos_s2, const int pos_v) {
  int aux;
  int& step = next[pos_s1][pos_s2][pos_v];
  bool& seen = solved[pos_s1][pos_s2][pos_v];
  int& best = solution[pos_s1][pos_s2][pos_v];
  if (seen++) {
    return best;
  }
  if (pos_v == virus.size()) {
    return best = -INF;
  }
  if (pos_s1 == s1.size() || pos_s2 == s2.size()) {
    return best = 0;
  }
  best = -INF;
  if (s1[pos_s1] == s2[pos_s2]) {
    aux = pos_v;
    while (aux != -1 && virus[aux] != s1[pos_s1]) {
      aux = failure[aux];
    }
    if ((aux = 1 + longest_match(pos_s1 + 1, pos_s2 + 1, aux + 1)) > best) {
      best = aux;
      step = BOTH;
    }
  }
  if ((aux = longest_match(pos_s1 + 1, pos_s2, pos_v)) > best) {
    best = aux;
    step = LEFT;
  }
  if ((aux = longest_match(pos_s1, pos_s2 + 1, pos_v)) > best) {
    best = aux;
    step = RIGHT;
  }
  return best;
}
int main(void) {
  int pos_s1, pos_s2, pos_v, best;
  std::string result;
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);
  std::cin >> s1 >> s2 >> virus;
  fill_failure();
  best = longest_match(0, 0, 0);
  if (best <= 0) {
    std::cout << 0 << std::endl;
  } else {
    pos_s1 = pos_s2 = pos_v = 0;
    while (pos_s1 != s1.size() && pos_s2 != s2.size()) {
      if (next[pos_s1][pos_s2][pos_v] == LEFT) {
        ++pos_s1;
      } else if (next[pos_s1][pos_s2][pos_v] == RIGHT) {
        ++pos_s2;
      } else {
        result += s1[pos_s1];
        while (pos_v != -1 && virus[pos_v] != s1[pos_s1]) {
          pos_v = failure[pos_v];
        }
        ++pos_v;
        ++pos_s1;
        ++pos_s2;
      }
    }
    std::cout << result << std::endl;
  }
  return 0;
}