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 s, s2, virus;
pair<string, int> dp[102][102][102];
int p[302];
int main() {
  cin >> s >> s2 >> virus;
  virus += '#';
  for (int i = 0; i <= s.size(); i++) {
    for (int j = 0; j <= s2.size(); j++) {
      if (i < s.size() && j < s2.size() && s[i] == s2[j]) {
        for (int t = 0; t < (int)virus.size() - 1; t++) {
          string ex = dp[i][j][t].first + s[i];
          ex = virus + ex;
          fill(p, p + ex.size(), 0);
          int mx = 0;
          for (int o = 1; o < ex.size(); o++) {
            int oj = p[o - 1];
            while (oj > 0 && ex[oj] != ex[o]) {
              oj = p[oj - 1];
            }
            if (ex[oj] == ex[o]) {
              oj++;
            }
            p[o] = oj;
            mx = max(oj, mx);
          }
          if (mx < (int)virus.size() - 1) {
            if (dp[i + 1][j + 1][mx].second < dp[i][j][t].second + 1) {
              dp[i + 1][j + 1][mx] = {dp[i][j][t].first + s[i],
                                      dp[i][j][t].second + 1};
            }
          }
        }
      }
      for (int t = 0; t < (int)virus.size() - 1; t++) {
        if (i + 1 <= s.size() && dp[i + 1][j][t].second < dp[i][j][t].second) {
          dp[i + 1][j][t] = dp[i][j][t];
        }
        if (j + 1 <= s2.size() && dp[i][j + 1][t].second < dp[i][j][t].second) {
          dp[i][j + 1][t] = dp[i][j][t];
        }
      }
    }
  }
  string ans;
  int mx = 0;
  for (int i = 0; i < (int)virus.size() - 1; i++) {
    if (mx < dp[(int)s.size()][(int)s2.size()][i].second) {
      mx = dp[(int)s.size()][(int)s2.size()][i].second;
      ans = dp[(int)s.size()][(int)s2.size()][i].first;
    }
  }
  if (mx == 0) {
    cout << mx;
    return 0;
  }
  cout << ans;
}