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;
const int N = 150;
const int inf = -1e9;
string s1, s2, virus;
int p[N], nxt[N][30], dp[N][N][N];
inline void prefix_map() {
  p[0] = 0;
  int n = int(virus.size());
  virus.push_back('$');
  for (int i = int(1); i < int(n); ++i) {
    p[i] = p[i - 1];
    while (p[i] && virus[i] != virus[p[i]]) p[i] = p[p[i] - 1];
    if (virus[i] == virus[p[i]]) p[i]++;
  }
  for (int i = int(0); i < int(n + 1); ++i)
    for (int j = int(0); j < int(26); ++j) {
      nxt[i][j] = i;
      while (nxt[i][j] && (virus[nxt[i][j]] != (j + 'A')))
        nxt[i][j] = p[nxt[i][j] - 1];
      if (virus[nxt[i][j]] == (j + 'A')) nxt[i][j]++;
    }
}
inline int solve(int pf, int c1, int c2) {
  if (c1 == int(s1.size())) return dp[pf][c1][c2] = 0;
  if (c2 == int(s2.size())) return dp[pf][c1][c2] = 0;
  int &ans = dp[pf][c1][c2];
  if (ans != inf) return ans;
  ans = max(solve(pf, c1 + 1, c2), solve(pf, c1, c2 + 1));
  if (s1[c1] == s2[c2]) {
    int nx = nxt[pf][s2[c2] - 'A'];
    if (nx != int(virus.size()) - 1)
      ans = max(ans, solve(nx, c1 + 1, c2 + 1) + 1);
  }
  return ans;
}
inline void imprime() {
  for (int i = int(0); i < int(int(virus.size())); ++i) {
    for (int j = int(0); j < int(int(s1.size())); ++j) {
      for (int k = int(0); k < int(int(s2.size())); ++k)
        cout << dp[i][j][k] << " ";
      cout << endl;
    }
    cout << endl << endl;
  }
}
inline void build() {
  int i = 0, j = 0;
  int pf = 0;
  string s;
  while (i < int(s1.size()) && j < int(s2.size())) {
    if (s1[i] == s2[j]) {
      int nx = nxt[pf][s2[j] - 'A'];
      if (dp[pf][i][j] == dp[nx][i + 1][j + 1] + 1) {
        s.push_back(s1[i]);
        i++;
        j++;
        pf = nx;
      } else {
        if (dp[pf][i][j] == dp[pf][i + 1][j])
          i++;
        else
          j++;
      }
    } else {
      if (dp[pf][i][j] == dp[pf][i + 1][j])
        i++;
      else
        j++;
    }
  }
  if (int(s.size()) != 0)
    cout << s << endl;
  else
    cout << "0" << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s1 >> s2 >> virus;
  prefix_map();
  for (int i = int(0); i < int(105); ++i)
    for (int j = int(0); j < int(105); ++j)
      for (int k = int(0); k < int(105); ++k) dp[i][j][k] = inf;
  int lel = solve(0, 0, 0);
  build();
  return 0;
}