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;
const int N = 113;
int go[N][26], dp[N][N][N];
struct Triple {
  int first, second, third;
};
Triple anc[N][N][N];
vector<int> prf(string s) {
  int n = s.size();
  vector<int> ans(n);
  for (int i = 1; i < n; i++) {
    int t = ans[i - 1];
    while (t > 0 && s[t] != s[i]) t = ans[t - 1];
    if (s[t] == s[i]) t++;
    ans[i] = t;
  }
  return ans;
}
void build(string s) {
  vector<int> p = prf(s);
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < 26; j++) {
      if (s[i] == 'A' + j)
        go[i][j] = i + 1;
      else {
        if (i)
          go[i][j] = go[p[i - 1]][j];
        else
          go[i][j] = 0;
      }
    }
  }
}
signed main() {
  string s, t, virus;
  cin >> s >> t >> virus;
  int n = s.size(), m = t.size(), k = virus.size();
  build(virus);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int g = 0; g < k; g++) {
        if (s[i] == t[j] &&
            dp[i + 1][j + 1][go[g][s[i] - 'A']] < dp[i][j][g] + 1) {
          dp[i + 1][j + 1][go[g][s[i] - 'A']] = dp[i][j][g] + 1;
          anc[i + 1][j + 1][go[g][s[i] - 'A']] = {i, j, g};
        }
        if (dp[i + 1][j][g] < dp[i][j][g])
          dp[i + 1][j][g] = dp[i][j][g], anc[i + 1][j][g] = {i, j, g};
        if (dp[i][j + 1][g] < dp[i][j][g])
          dp[i][j + 1][g] = dp[i][j][g], anc[i][j + 1][g] = {i, j, g};
        if (dp[i + 1][j + 1][g] < dp[i][j][g])
          dp[i + 1][j + 1][g] = dp[i][j][g], anc[i + 1][j + 1][g] = {i, j, g};
      }
    }
    for (int g = 0; g < k; g++) {
      if (dp[i + 1][m][g] < dp[i][m][g])
        dp[i + 1][m][g] = dp[i][m][g], anc[i + 1][m][g] = {i, m, g};
    }
  }
  int ans = 0;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < m; j++) {
      if (dp[n][j][i] > dp[n][j + 1][i])
        dp[n][j + 1][i] = dp[n][j][i], anc[n][j + 1][i] = {n, j, i};
    }
  }
  for (int i = 0; i < k; i++) ans = max(ans, dp[n][m][i]);
  Triple tr = {0, 0, 0};
  for (int i = 0; i < k; i++) {
    if (dp[n][m][i] == ans) tr = {n, m, i};
  }
  if (!ans) {
    cout << ans << endl;
    return 0;
  }
  string a;
  while (tr.first || tr.second) {
    Triple ancestor = anc[tr.first][tr.second][tr.third];
    if (dp[ancestor.first][ancestor.second][ancestor.third] + 1 ==
        dp[tr.first][tr.second][tr.third])
      a.push_back(s[tr.first - 1]);
    tr = ancestor;
  }
  reverse(a.begin(), a.end());
  cout << a << endl;
}