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, s3, s4;
int dp[101][101][101], lmt, sdp[101][101];
map<string, int> m;
vector<string> sv;
int gen(string xz) {
  for (int i = 0; i <= s3.size(); i++) sv.push_back(s3.substr(0, i));
  for (auto ix : sv) {
    string s = ix;
    for (int k = 'A'; k <= 'Z'; k++) {
      s.push_back(k);
      for (int j = 0; j < s.size(); j++) {
        int jj = 0, cnt = 0;
        bool br = 0;
        for (int i = 0; i + j < s.size() and jj < s3.size(); i++) {
          if (s[i + j] == s3[jj])
            jj++, cnt++;
          else {
            br = 1;
            break;
          }
        }
        if (!br)
          sdp[s.size() - 1][(int)s.back()] =
              max(cnt, sdp[s.size() - 1][(int)s.back()]);
      }
      if (sdp[s.size() - 1][(int)s.back()] == -1)
        sdp[s.size() - 1][(int)s.back()] = 0;
      s.pop_back();
    }
  }
  return 1;
}
bool printed = 0;
int lcs(int i, int j, int mi) {
  if (mi == s3.size()) return INT_MIN;
  if (i == s1.size() || j == s2.size()) return 0;
  if (dp[i][j][mi] != -1) return dp[i][j][mi];
  int x, y, z;
  x = y = z = INT_MIN;
  if (s1[i] == s2[j]) x = 1 + lcs(i + 1, j + 1, sdp[mi][(int)s1[i]]);
  y = lcs(i + 1, j, mi);
  z = lcs(i, j + 1, mi);
  return dp[i][j][mi] = max({x, y, z});
}
void print(int i, int j, int mi) {
  if (i == s1.size() || j == s2.size()) {
    return;
  }
  int re = lcs(i, j, mi);
  if (s1[i] == s2[j] and re == 1 + lcs(i + 1, j + 1, sdp[mi][(int)s1[i]])) {
    cout << s1[i];
    print(i + 1, j + 1, sdp[mi][(int)s1[i]]);
    return;
  }
  if (re == lcs(i + 1, j, mi)) {
    print(i + 1, j, mi);
    return;
  } else
    print(i, j + 1, mi);
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  memset(dp, -1, sizeof dp);
  memset(sdp, -1, sizeof sdp);
  cin >> s1 >> s2 >> s3;
  s4 = s3;
  gen(s4);
  int ans = lcs(0, 0, 0);
  if (!ans) return cout << "0", 0;
  print(0, 0, 0);
}