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>
#pragma GCC optimize("O3")
using namespace std;
const long long N = 1e4 + 5, SEG = (1 << 19);
string s1, s2, s3;
int n, m;
int solve(int p1, int p2, int k) {
  if (k == s3.size()) return -1e9 + 6;
  if (p1 > n || p2 > m) return -1e9 + 6;
  if (p1 == n || p2 == m) return 0;
  int x = solve(p1 + 1, p2, k);
  x = max(x, solve(p1, p2 + 1, k));
  if (s1[p1] == s2[p2]) {
    int kk = k;
    if (s1[p1] == s3[k])
      kk++;
    else
      kk = 0;
    x = max(x, solve(p1 + 1, p2 + 1, kk) + 1);
  }
  return x;
}
long long dp[105][105][105] = {};
struct dir {
  bool pr = 0;
  int nxi, nxj, nxk;
};
dir dp2[105][105][105];
int cc;
void print(int i, int j, int k, int cnt) {
  if (cnt == cc) return;
  if (dp2[i][j][k].pr) {
    cout << s1[i];
    cnt++;
  }
  print(dp2[i][j][k].nxi, dp2[i][j][k].nxj, dp2[i][j][k].nxk, cnt);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> s1 >> s2 >> s3;
  n = s1.size();
  m = s2.size();
  int ff[s3.size()];
  ff[0] = 0;
  for (int i = 1; i < s3.size(); i++) {
    int j = ff[i - 1];
    while (j > 0 && s3[j] != s3[i]) {
      j = ff[j - 1];
    }
    if (s3[j] == s3[i]) j++;
    ff[i] = j;
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      dp[i][j][s3.size()] = -1e9 + 6;
    }
  }
  for (int k = 0; k < 105; k++) {
    dp[n + 1][m + 1][k] = -1e9 + 6;
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = m - 1; j >= 0; j--) {
      for (int k = 0; k < s3.size(); k++) {
        int x = dp[i + 1][j][k];
        dp2[i][j][k].nxi = i + 1;
        dp2[i][j][k].nxj = j;
        dp2[i][j][k].nxk = k;
        int y = dp[i][j + 1][k];
        if (y > x) {
          dp2[i][j][k].nxi = i;
          dp2[i][j][k].nxj = j + 1;
          dp2[i][j][k].nxk = k;
        }
        y = max(x, y);
        int z = 0;
        if (s1[i] == s2[j]) {
          int kk = k;
          while (kk > 0 && s1[i] != s3[kk]) kk = ff[kk - 1];
          if (s1[i] == s3[kk]) kk++;
          z = dp[i + 1][j + 1][kk] + 1;
          if (z > y) {
            dp2[i][j][k].nxi = i + 1;
            dp2[i][j][k].nxj = j + 1;
            dp2[i][j][k].nxk = kk;
            dp2[i][j][k].pr = 1;
          }
        }
        dp[i][j][k] = max(x, max(y, z));
      }
    }
  }
  cc = dp[0][0][0];
  if (cc == 0)
    cout << '0';
  else
    print(0, 0, 0, 0);
  return 0;
}