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, v;
int dp[101][101][101];
string ans[101][101][101];
int t[101][26];
int main() {
  cin >> s1 >> s2 >> v;
  int mx = 0;
  string javab = "";
  for (int i = 0; i < v.size(); i++)
    for (int j = 0; j < 26; j++) {
      string tmp = v.substr(0, i);
      tmp += 'A' + j;
      t[i][j] = 0;
      for (int k = 0; k < tmp.size(); k++)
        if (v.substr(0, k + 1) == tmp.substr(tmp.size() - k - 1))
          t[i][j] = k + 1;
    }
  for (int i = 0; i < s1.size(); i++) {
    for (int j = 0; j < s2.size(); j++) {
      for (int k = 0; k < v.size(); k++) {
        if (i > 0) {
          dp[i][j][k] = dp[i - 1][j][k];
          ans[i][j][k] = ans[i - 1][j][k];
        }
        if (j > 0 && dp[i][j - 1][k] > dp[i][j][k]) {
          dp[i][j][k] = dp[i][j - 1][k];
          ans[i][j][k] = ans[i][j - 1][k];
        }
        if (s1[i] == s2[j]) {
          if (k == 0) {
            if (i == 0 || j == 0) {
              if (s1[i] != v[0]) {
                dp[i][j][k] = 1;
                ans[i][j][k] = s1[i];
              }
            } else {
              for (int l = 0; l < v.size(); l++) {
                if (t[l][s1[i] - 'A'] == 0) {
                  if (dp[i - 1][j - 1][l] + 1 > dp[i][j][0]) {
                    dp[i][j][0] = dp[i - 1][j - 1][l] + 1;
                    ans[i][j][0] = ans[i - 1][j - 1][l] + s1[i];
                  }
                }
              }
            }
          } else {
            if (i == 0 || j == 0) {
              if (k == 1 && s1[i] == v[0]) {
                dp[i][j][k] = 1;
                ans[i][j][k] = s1[i];
              }
            } else {
              for (int l = 0; l < v.size(); l++) {
                if (t[l][s1[i] - 'A'] == k) {
                  if (dp[i - 1][j - 1][l] + 1 > dp[i][j][k]) {
                    dp[i][j][k] = dp[i - 1][j - 1][l] + 1;
                    ans[i][j][k] = ans[i - 1][j - 1][l] + s1[i];
                  }
                }
              }
            }
          }
        }
        if (dp[i][j][k] > mx) {
          mx = dp[i][j][k];
          javab = ans[i][j][k];
        }
      }
    }
  }
  if (mx > 0)
    cout << javab << endl;
  else
    cout << 0 << endl;
  return 0;
}