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;
int n, n1, n2;
string s1, s2, s;
pair<int, string> dp[100][100][100];
int lps[100];
int func(int k, char ch) {
  if (k == 0) {
    return 0;
  }
  int len = lps[k - 1];
  while (true) {
    if (s[len] == ch) {
      return len + 1;
    } else {
      if (len != 0) {
        len = lps[len - 1];
      } else {
        return 0;
      }
    }
  }
}
void make_lps() {
  int len = 0;
  int i = 1;
  lps[0] = 0;
  while (i < n) {
    if (s[len] == s[i]) {
      lps[i] = len + 1;
      len++;
      i++;
    } else {
      if (len != 0) {
        len = lps[len - 1];
      } else {
        lps[i] = 0;
        i++;
      }
    }
  }
}
int g = 0;
pair<int, string> rec(int i, int j, int k) {
  if (i == n1 || j == n2) {
    return make_pair(0, "");
  }
  if (dp[i][j][k].first != -1) {
    return dp[i][j][k];
  }
  int mx = 0, t;
  string a = "";
  if (rec(i, j + 1, k).first > mx) {
    mx = rec(i, j + 1, k).first;
    a = rec(i, j + 1, k).second;
  }
  if (rec(i + 1, j, k).first > mx) {
    mx = rec(i + 1, j, k).first;
    a = rec(i + 1, j, k).second;
  }
  if (s1[i] == s2[j]) {
    if (s1[i] != s[k]) {
      t = func(k, s1[i]);
      if (1 + rec(i + 1, j + 1, t).first > mx) {
        mx = 1 + rec(i + 1, j + 1, t).first;
        a = s1[i] + rec(i + 1, j + 1, t).second;
      }
    } else {
      if (k != n - 1 && 1 + rec(i + 1, j + 1, k + 1).first > mx) {
        mx = 1 + rec(i + 1, j + 1, k + 1).first;
        a = s1[i] + rec(i + 1, j + 1, k + 1).second;
      }
    }
  }
  return dp[i][j][k] = make_pair(mx, a);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, j, k;
  pair<int, string> pr;
  cin >> s1 >> s2 >> s;
  n = s.length();
  n1 = s1.length();
  n2 = s2.length();
  make_lps();
  for (i = 0; i < 100; i++) {
    for (j = 0; j < 100; j++) {
      for (k = 0; k < 100; k++) {
        dp[i][j][k] = make_pair(-1, "");
      }
    }
  }
  pr = rec(0, 0, 0);
  if (pr.first) {
    cout << pr.second;
  } else {
    cout << "0";
  }
  return 0;
}