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 inf = 1 << 30;
const int N = 102, mod = 1000000007;
vector<int> compute_prefix(string s) {
  vector<int> pi(s.size(), -1);
  int k = -1;
  for (int i = 1; i < s.size(); i++) {
    while (k >= 0 && s[k + 1] != s[i]) k = pi[k];
    if (s[k + 1] == s[i]) k++;
    pi[i] = k;
  }
  return pi;
}
char s1[N], s2[N], s3[N];
vector<int> pi;
int n, m, k;
int mem[N][N][N];
int sol[N][N][N];
int dp(int i, int j, int mm) {
  if (mm == (int)pi.size() - 1) return -inf;
  if (i >= n || j >= m) return 0;
  int &ret = mem[i][j][mm + 1];
  if (ret != -1) return ret;
  int c1 = dp(i + 1, j, mm);
  int c2 = dp(i, j + 1, mm);
  ret = max(c1, c2);
  if (c1 > c2)
    sol[i][j][mm + 1] = -10;
  else
    sol[i][j][mm + 1] = -20;
  if (s1[i] == s2[j]) {
    int ma = mm;
    while (ma > -1 && s3[ma + 1] != s1[i]) ma = pi[ma];
    if (s3[ma + 1] == s1[i]) ma++;
    int c3 = dp(i + 1, j + 1, ma) + 1;
    if (c3 >= ret) {
      ret = c3;
      sol[i][j][mm + 1] = ma;
    }
  }
  return ret;
}
void build_sol(int i, int j, int mm) {
  if (mm == (int)pi.size() - 1) return;
  if (i >= n || j >= m) return;
  if (sol[i][j][mm + 1] == -10) {
    return build_sol(i + 1, j, mm);
  }
  if (sol[i][j][mm + 1] == -20) {
    return build_sol(i, j + 1, mm);
  }
  printf("%c", s1[i]);
  return build_sol(i + 1, j + 1, sol[i][j][mm + 1]);
}
int main() {
  scanf("%s", s1);
  scanf("%s", s2);
  scanf("%s", s3);
  n = strlen(s1);
  m = strlen(s2);
  k = strlen(s3);
  pi = compute_prefix(s3);
  memset(mem, -1, sizeof mem);
  int ANS = dp(0, 0, -1);
  if (ANS <= 0) {
    printf("0\n");
    return 0;
  }
  build_sol(0, 0, -1);
  return 0;
}