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 s1, s2, virus;
pair<int, int> dp[105][105][105];
int l1, l2, lvirus;
string ans = "";
int pi[105];
void pf(string s) {
  memset(pi, 0, sizeof(pi));
  int n = (int)s.length();
  for (int i = 1; i < n; ++i) {
    int j = pi[i - 1];
    while (j > 0 && s[i] != s[j]) j = pi[j - 1];
    if (s[i] == s[j]) ++j;
    pi[i] = j;
  }
}
int main() {
  cin >> s1 >> s2 >> virus;
  l1 = s1.length();
  l2 = s2.length();
  lvirus = virus.length();
  int i, j, k;
  for (i = 1; i <= l1; i++) {
    for (j = 1; j <= l2; j++) {
      for (k = 0; k < lvirus; k++) {
        if (dp[i][j][k].first <= dp[i - 1][j][k].first) {
          dp[i][j][k].first = dp[i - 1][j][k].first;
          dp[i][j][k].second = 1;
        }
        if (dp[i][j][k].first <= dp[i][j - 1][k].first) {
          dp[i][j][k].first = dp[i][j - 1][k].first;
          dp[i][j][k].second = 2;
        }
        if (s1[i - 1] == s2[j - 1]) {
          if (k != 0 && s1[i - 1] == virus[k - 1]) {
            if (dp[i][j][k].first < dp[i - 1][j - 1][k - 1].first + 1) {
              dp[i][j][k].first = dp[i - 1][j - 1][k - 1].first + 1;
              dp[i][j][k].second = 3;
            }
          }
          int z = k;
          if (s1[i - 1] != virus[z]) {
            char c = virus[z];
            virus[z] = s1[i - 1];
            pf(virus);
            int v = pi[z];
            if (dp[i][j][v].first < dp[i - 1][j - 1][z].first + 1) {
              dp[i][j][v].first = dp[i - 1][j - 1][z].first + 1;
              dp[i][j][v].second = 10 + z;
            }
            virus[z] = c;
          }
        }
      }
    }
  }
  int mx = 0, cur = -1;
  for (i = 0; i < lvirus; i++) {
    if (mx <= dp[l1][l2][i].first) {
      cur = i;
      mx = dp[l1][l2][i].first;
    }
  }
  if (mx == 0) {
    cout << 0;
    return 0;
  }
  i = l1;
  j = l2;
  while (i != 0 && j != 0) {
    if (dp[i][j][cur].second == 1) {
      i--;
      continue;
    }
    if (dp[i][j][cur].second == 2) {
      j--;
      continue;
    }
    if (dp[i][j][cur].second == 3) {
      ans = s1[i - 1] + ans;
      i--;
      j--;
      cur--;
      continue;
    }
    ans = s1[i - 1] + ans;
    cur = dp[i][j][cur].second - 10;
    i--;
    j--;
  }
  cout << ans;
  return 0;
}