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;
const int N = 105;
int dp[N][N][N];
int lps[N];
string a, b, v;
int n, m, len;
void kmppreprocess(string s) {
  lps[0] = -1;
  int i = 0;
  int j = -1;
  int n = s.size();
  while (i < n) {
    while (j >= 0 && s[i] != s[j]) j = lps[j];
    i++;
    j++;
    lps[i] = j;
  }
}
int search(char ch, int pos, string s) {
  while (pos >= 0 && ch != s[pos]) pos = lps[pos];
  pos++;
  return pos;
}
int rec(int x, int y, int z) {
  if (z == len) return -1000000007;
  if (x == n && y == m) return 0;
  if (x > n || y > m) return -1000000007;
  if (dp[x][y][z] != -1) return dp[x][y][z];
  int ans = -1000000007;
  ans = max(ans, rec(x + 1, y, z));
  ans = max(ans, rec(x, y + 1, z));
  if (a[x] == b[y]) {
    ans = max(ans, 1 + rec(x + 1, y + 1, search(a[x], z, v)));
  }
  return dp[x][y][z] = ans;
}
string solve(int x, int y, int z) {
  if (x == n && y == m) return "";
  if (rec(x + 1, y, z) == rec(x, y, z))
    return solve(x + 1, y, z);
  else if (rec(x, y + 1, z) == rec(x, y, z))
    return solve(x, y + 1, z);
  else
    return a[x] + solve(x + 1, y + 1, search(a[x], z, v));
}
int main() {
  cin >> a >> b >> v;
  n = a.size();
  m = b.size();
  len = v.size();
  kmppreprocess(v);
  memset(dp, -1, sizeof(dp));
  int ans = rec(0, 0, 0);
  if (ans <= 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << solve(0, 0, 0) << endl;
}