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 s1, s2, virus;
string dp[110][110][110];
bool marked[110][110][110];
int d2[110][30];
bool canGo[110][110];
string maxi(string a, string b) {
  if (a.length() > b.length())
    return a;
  else
    return b;
}
string maxLength(int i, int j, int k) {
  if (i < 0 || j < 0 || k < 0) return "";
  if (marked[i][j][k]) return dp[i][j][k];
  marked[i][j][k] = true;
  dp[i][j][k] = maxi(maxLength(i - 1, j, k), maxLength(i, j - 1, k));
  if (s1[i] == s2[j])
    if (s1[i] == virus[k]) {
      if (k != 0)
        dp[i][j][k] = maxi(dp[i][j][k], maxLength(i - 1, j - 1, k - 1) + s1[i]);
    } else
      dp[i][j][k] = maxi(dp[i][j][k],
                         maxLength(i - 1, j - 1, d2[k][s1[i] - 'A']) + s1[i]);
  return dp[i][j][k];
}
int main() {
  memset(marked, false, sizeof marked);
  cin >> s1 >> s2 >> virus;
  canGo[virus.length()][virus.length()] = true;
  for (int i = 0; i < virus.length(); i++) {
    canGo[virus.length()][i] = true;
    for (int j = 0; j < virus.length(); j++) {
      int t1 = i, t2 = j;
      while (t1 < virus.length() && t2 < virus.length())
        if (virus[t1] != virus[t2])
          break;
        else
          t1++, t2++;
      if (t1 == virus.length())
        canGo[i][j] = true;
      else
        canGo[i][j] = false;
    }
  }
  for (int i = 0; i < virus.length(); i++)
    for (int j = 0; j < 26; j++) {
      d2[i][j] = virus.length() - 1;
      for (int k = i; k < virus.length(); k++) {
        if ((virus[k] == char(j + 'A')) && canGo[k + 1][i + 1]) {
          d2[i][j] = k - 1;
          break;
        }
      }
    }
  string s = maxLength(s1.length() - 1, s2.length() - 1, virus.length() - 1);
  if (s == "")
    cout << 0 << endl;
  else
    cout << s << endl;
}