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, s3;
int z[2000006];
string s;
void calc() {
  memset(z, 0, sizeof(z));
  int l = 0, r = 0;
  int len = s.size();
  for (int i = 1; i < len; i++) {
    if (i > r) {
      l = r = i;
      while (r < len && s[r] == s[r - l]) r++;
      z[i] = r - l;
      r--;
    } else {
      if (z[i - l] < r - i + 1)
        z[i] = z[i - l];
      else {
        l = i;
        while (r < len && s[r] == s[r - l]) r++;
        z[i] = r - l;
        r--;
      }
    }
  }
}
void zf() {
  s = s3 + '$' + s3;
  calc();
  for (int i = 0; i < s3.size(); i++) {
    z[i] = z[i + s3.size() + 1];
  }
}
struct info {
  int l, r, idx;
};
int dp[105][105][105];
info dir[105][105][105];
int f(int l, int r, int idx) {
  if (idx == s3.size()) return -INT_MAX / 2;
  if (l == s1.size() || r == s2.size()) return 0;
  if (dp[l][r][idx] != -1) return dp[l][r][idx];
  int ans = 0;
  if (s1[l] == s2[r]) {
    int mx = 0;
    for (int i = 0; i < idx + 1; i++)
      if (z[i] + i >= idx && s1[l] == s3[idx - i]) mx = max(mx, idx - i + 1);
    dir[l][r][idx] = {l + 1, r + 1, mx};
    ans = 1 + f(l + 1, r + 1, mx);
  }
  int tem1 = f(l, r + 1, idx);
  int tem2 = f(l + 1, r, idx);
  if (tem1 >= ans) {
    ans = tem1;
    dir[l][r][idx] = {l, r + 1, idx};
  }
  if (tem2 >= ans) {
    ans = tem2;
    dir[l][r][idx] = {l + 1, r, idx};
  }
  return dp[l][r][idx] = ans;
}
string ans;
int lala;
void print(int l, int r, int idx) {
  lala++;
  if (l >= s1.size() || r >= s2.size() || idx == s3.size()) return;
  info gg = dir[l][r][idx];
  if (gg.l == l + 1 && gg.r == r + 1) ans += s1[l];
  print(gg.l, gg.r, gg.idx);
}
int main() {
  cin >> s1 >> s2 >> s3;
  zf();
  memset(dp, -1, sizeof(dp));
  int szz = f(0, 0, 0);
  if (!szz) {
    cout << 0 << '\n';
    return 0;
  }
  print(0, 0, 0);
  cout << ans << '\n';
  return 0;
}