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;
long long dp[110][110][110], pi[110];
vector<long long> trace[110][110][110];
bool valid[110][110][110];
string virus;
void kmpPreprocess() {
  long long i = 0, j = -1;
  pi[0] = -1;
  while (i < virus.size()) {
    while (j >= 0 && virus[i] != virus[j]) {
      j = pi[j];
    }
    i++, j++;
    pi[i] = j;
  }
}
long long nextlen(long long pre, char next) {
  long long j = pre;
  while (j > 0 && virus[j] != next) {
    j = pi[j];
  }
  if (virus[j] == next) {
    return j + 1;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s1, s2;
  cin >> s1 >> s2 >> virus;
  s1 += '#';
  s2 += '$';
  kmpPreprocess();
  for (int i = 0; i <= s1.size(); i++) {
    valid[i][0][0] = 1;
  }
  for (int i = 0; i <= s2.size(); i++) {
    valid[0][i][0] = 1;
  }
  for (int i = 0; i < s1.size(); i++) {
    for (int j = 0; j < s2.size(); j++) {
      for (int k = 0; k < virus.size(); k++) {
        if (!valid[i][j][k]) continue;
        if (s1[i] == s2[j]) {
          if (s1[i] == virus[k]) {
            valid[i + 1][j + 1][k + 1] = 1;
            if (dp[i + 1][j + 1][k + 1] <= dp[i][j][k] + 1) {
              dp[i + 1][j + 1][k + 1] = dp[i][j][k] + 1;
              trace[i + 1][j + 1][k + 1] = {i, j, k, 1};
            }
          } else {
            long long tmp = nextlen(k, s1[i]);
            valid[i + 1][j + 1][tmp] = 1;
            if (dp[i + 1][j + 1][tmp] <= dp[i][j][k] + 1) {
              dp[i + 1][j + 1][tmp] = dp[i][j][k] + 1;
              trace[i + 1][j + 1][tmp] = {i, j, k, 1};
            }
          }
        }
        valid[i + 1][j][k] = 1;
        if (dp[i + 1][j][k] <= dp[i][j][k]) {
          dp[i + 1][j][k] = dp[i][j][k];
          trace[i + 1][j][k] = {i, j, k, 0};
        }
        valid[i][j + 1][k] = 1;
        if (dp[i][j + 1][k] <= dp[i][j][k]) {
          dp[i][j + 1][k] = dp[i][j][k];
          trace[i][j + 1][k] = {i, j, k, 0};
        }
        valid[i + 1][j + 1][k] = 1;
        if (dp[i + 1][j + 1][k] <= dp[i][j][k]) {
          dp[i + 1][j + 1][k] = dp[i][j][k];
          trace[i + 1][j + 1][k] = {i, j, k, 0};
        }
      }
    }
  }
  long long mx = 0, nk = -1, ni = s1.size(), nj = s2.size();
  for (int i = 0; i < virus.size(); i++) {
    if (mx < dp[ni][nj][i]) {
      mx = dp[ni][nj][i];
      nk = i;
    }
  }
  string ans;
  if (mx == 0) {
    cout << mx << '\n';
    return 0;
  }
  while (ans.size() != mx) {
    vector<long long> tmp = trace[ni][nj][nk];
    ni = tmp[0], nj = tmp[1], nk = tmp[2];
    if (tmp[3]) {
      ans += s1[ni];
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << '\n';
}