#include <bits/stdc++.h>
using namespace std;
bool compare1(pair<long long, pair<long long, long long>> a1,
              pair<long long, pair<long long, long long>> a2) {
  return a1.first > a2.first;
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void compute(string pat, int M, int* lps) {
  int len = 0;
  lps[0] = 0;
  int i = 1;
  while (i < M) {
    if (pat[i] == pat[len]) {
      len++;
      lps[i] = len;
      i++;
    } else {
      if (len != 0) {
        len = lps[len - 1];
      } else {
        lps[i] = 0;
        i++;
      }
    }
  }
}
int dp[101][101][101];
int solve(int idx1, int idx2, int idx3, string s1, string s2, string s3,
          int arr[]) {
  if (idx1 >= s1.length() || idx2 >= s2.length()) return 0;
  if (dp[idx1][idx2][idx3] != -1) return dp[idx1][idx2][idx3];
  int k = 0;
  k = max(k, max(solve(idx1 + 1, idx2, idx3, s1, s2, s3, arr),
                 solve(idx1, idx2 + 1, idx3, s1, s2, s3, arr)));
  if (s1[idx1] == s2[idx2]) {
    if (idx3 != s3.length() - 1 && s3[idx3] == s1[idx1])
      k = max(k, solve(idx1 + 1, idx2 + 1, idx3 + 1, s1, s2, s3, arr) + 1);
    else if (s1[idx1] != s3[idx3]) {
      int t1 = idx3 - 1 > 0 ? arr[idx3 - 1] : 0;
      while (t1 > 0) {
        if (s3[t1] != s1[idx1])
          t1 = arr[t1 - 1];
        else
          break;
      }
      if (s1[idx1] == s3[t1]) t1++;
      k = max(k, solve(idx1 + 1, idx2 + 1, t1, s1, s2, s3, arr) + 1);
    }
  }
  dp[idx1][idx2][idx3] = k;
  return k;
}
int main() {
  string s1;
  string s2;
  string s3;
  cin >> s1 >> s2 >> s3;
  memset(dp, -1, sizeof dp);
  int arr[s3.length() + 1];
  compute(s3, s3.length(), arr);
  int k1 = solve(0, 0, 0, s1, s2, s3, arr);
  int i = 0;
  int j = 0;
  int k = 0;
  string ans = "";
  while (i < s1.length() && j < s2.length() && k < s3.length()) {
    if (s1[i] != s2[j]) {
      if (dp[i][j][k] == dp[i + 1][j][k])
        i++;
      else if (dp[i][j][k] == dp[i][j + 1][k])
        j++;
      else
        break;
    } else {
      if (k != s3.length() - 1 && s1[i] == s3[k]) {
        if (dp[i][j][k] == dp[i + 1][j + 1][k + 1] + 1) {
          ans += s1[i];
          i++;
          j++;
          k++;
        } else if (dp[i][j][k] == dp[i + 1][j][k]) {
          i++;
        } else if (dp[i][j][k] == dp[i][j + 1][k]) {
          j++;
        } else
          break;
      } else if (s1[i] != s3[k]) {
        int t1 = k - 1 > 0 ? arr[k - 1] : 0;
        while (t1 > 0) {
          if (s3[t1] != s1[i])
            t1 = arr[t1 - 1];
          else
            break;
        }
        if (s1[i] == s3[t1]) t1++;
        if (dp[i][j][k] == dp[i + 1][j + 1][t1] + 1) {
          ans += s1[i];
          i++;
          j++;
          k = t1;
        } else if (dp[i][j][k] == dp[i + 1][j][k]) {
          i++;
        } else if (dp[i][j][k] == dp[i][j + 1][k]) {
          j++;
        } else
          break;
      } else {
        if (dp[i][j][k] == dp[i + 1][j][k])
          i++;
        else if (dp[i][j][k] == dp[i][j + 1][k])
          j++;
        else
          break;
      }
    }
  }
  if (k1 != 0) {
    if (i < s1.length() && j < s2.length() && s1[i] == s2[j] &&
        !(k == s3.length() - 1 && s1[i] == s3[k]))
      ans += s1[i];
    cout << ans;
  } else
    cout << "0";
}

### Prompt

Please create a solution in CPP to the following 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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool compare1(pair<long long, pair<long long, long long>> a1,
              pair<long long, pair<long long, long long>> a2) {
  return a1.first > a2.first;
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void compute(string pat, int M, int* lps) {
  int len = 0;
  lps[0] = 0;
  int i = 1;
  while (i < M) {
    if (pat[i] == pat[len]) {
      len++;
      lps[i] = len;
      i++;
    } else {
      if (len != 0) {
        len = lps[len - 1];
      } else {
        lps[i] = 0;
        i++;
      }
    }
  }
}
int dp[101][101][101];
int solve(int idx1, int idx2, int idx3, string s1, string s2, string s3,
          int arr[]) {
  if (idx1 >= s1.length() || idx2 >= s2.length()) return 0;
  if (dp[idx1][idx2][idx3] != -1) return dp[idx1][idx2][idx3];
  int k = 0;
  k = max(k, max(solve(idx1 + 1, idx2, idx3, s1, s2, s3, arr),
                 solve(idx1, idx2 + 1, idx3, s1, s2, s3, arr)));
  if (s1[idx1] == s2[idx2]) {
    if (idx3 != s3.length() - 1 && s3[idx3] == s1[idx1])
      k = max(k, solve(idx1 + 1, idx2 + 1, idx3 + 1, s1, s2, s3, arr) + 1);
    else if (s1[idx1] != s3[idx3]) {
      int t1 = idx3 - 1 > 0 ? arr[idx3 - 1] : 0;
      while (t1 > 0) {
        if (s3[t1] != s1[idx1])
          t1 = arr[t1 - 1];
        else
          break;
      }
      if (s1[idx1] == s3[t1]) t1++;
      k = max(k, solve(idx1 + 1, idx2 + 1, t1, s1, s2, s3, arr) + 1);
    }
  }
  dp[idx1][idx2][idx3] = k;
  return k;
}
int main() {
  string s1;
  string s2;
  string s3;
  cin >> s1 >> s2 >> s3;
  memset(dp, -1, sizeof dp);
  int arr[s3.length() + 1];
  compute(s3, s3.length(), arr);
  int k1 = solve(0, 0, 0, s1, s2, s3, arr);
  int i = 0;
  int j = 0;
  int k = 0;
  string ans = "";
  while (i < s1.length() && j < s2.length() && k < s3.length()) {
    if (s1[i] != s2[j]) {
      if (dp[i][j][k] == dp[i + 1][j][k])
        i++;
      else if (dp[i][j][k] == dp[i][j + 1][k])
        j++;
      else
        break;
    } else {
      if (k != s3.length() - 1 && s1[i] == s3[k]) {
        if (dp[i][j][k] == dp[i + 1][j + 1][k + 1] + 1) {
          ans += s1[i];
          i++;
          j++;
          k++;
        } else if (dp[i][j][k] == dp[i + 1][j][k]) {
          i++;
        } else if (dp[i][j][k] == dp[i][j + 1][k]) {
          j++;
        } else
          break;
      } else if (s1[i] != s3[k]) {
        int t1 = k - 1 > 0 ? arr[k - 1] : 0;
        while (t1 > 0) {
          if (s3[t1] != s1[i])
            t1 = arr[t1 - 1];
          else
            break;
        }
        if (s1[i] == s3[t1]) t1++;
        if (dp[i][j][k] == dp[i + 1][j + 1][t1] + 1) {
          ans += s1[i];
          i++;
          j++;
          k = t1;
        } else if (dp[i][j][k] == dp[i + 1][j][k]) {
          i++;
        } else if (dp[i][j][k] == dp[i][j + 1][k]) {
          j++;
        } else
          break;
      } else {
        if (dp[i][j][k] == dp[i + 1][j][k])
          i++;
        else if (dp[i][j][k] == dp[i][j + 1][k])
          j++;
        else
          break;
      }
    }
  }
  if (k1 != 0) {
    if (i < s1.length() && j < s2.length() && s1[i] == s2[j] &&
        !(k == s3.length() - 1 && s1[i] == s3[k]))
      ans += s1[i];
    cout << ans;
  } else
    cout << "0";
}

```