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;
struct edge {
  int u, v;
  long long w;
};
long long MOD = 1000000007;
long long _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 10;
void unko(string& s, string t) {
  if (s == "unko" || s.length() < t.length()) s = t;
}
int main() {
  string s1, s2, v;
  cin >> s1 >> s2 >> v;
  int n = v.length();
  vector<vector<int> > a(n, vector<int>(26));
  for (int l = 0; l < n; l++)
    for (int k = 0; k < 26; k++) {
      string s = v.substr(0, l) + string(1, 'A' + k);
      for (int _l = 0; _l <= l + 1; _l++)
        if (s.substr(l + 1 - _l, _l) == v.substr(0, _l)) a[l][k] = _l;
    }
  int n1 = s1.length(), n2 = s2.length();
  vector<vector<vector<string> > > dp(
      n1 + 1, vector<vector<string> >(n2 + 1, vector<string>(n, "unko")));
  dp[0][0][0] = "";
  for (int i = 0; i <= n1; i++)
    for (int j = 0; j <= n2; j++)
      for (int l = 0; l < n; l++) {
        if (dp[i][j][l] == "unko") continue;
        if (i + 1 <= n1) unko(dp[i + 1][j][l], dp[i][j][l]);
        if (j + 1 <= n2) unko(dp[i][j + 1][l], dp[i][j][l]);
        if (i + 1 <= n1 && j + 1 <= n2 && s1[i] == s2[j]) {
          int k = s1[i] - 'A', _l = a[l][k];
          if (_l < n)
            unko(dp[i + 1][j + 1][_l], dp[i][j][l] + string(1, 'A' + k));
        }
      }
  string ans = "unko";
  for (int l = 0; l < n; l++)
    if (dp[n1][n2][l] != "unko") unko(ans, dp[n1][n2][l]);
  if (ans == "unko" || ans == "")
    cout << 0 << endl;
  else
    cout << ans << endl;
}