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
#include <bits/stdc++.h>
using namespace std;
void RD(int &x) { scanf("%d", &x); }
void RD(long long &x) { scanf("%I64d", &x); }
void RD(double &x) { scanf("%lf", &x); }
void RD(int &x, int &y) { scanf("%d%d", &x, &y); }
void RD(long long &x, long long &y) { scanf("%I64d%I64d", &x, &y); }
void RD(double &x, double &y) { scanf("%lf%lf", &x, &y); }
void RD(char *s) { scanf("%s", s); }
void RD(char &s) { scanf("%c", &s); }
void RD(string &s) { cin >> s; }
void PR(int x) { printf("%d\n", x); }
void PR(int x, int y) { printf("%d %d\n", x, y); }
void PR(long long x) { printf("%I64d\n", x); }
void PR(char x) { printf("%c\n", x); }
void PR(char *x) { printf("%s\n", x); }
void PR(string x) { cout << x << endl; }
const long long inf = 1;
const long long mod = 1LL;
int par[110];
string s1, s2, pat;
void pre_process() {
  int i, k, n;
  n = (int)pat.size();
  k = 0;
  par[0] = 0;
  for (i = 1; i < n; i++) {
    while (k > 0 && pat[i] != pat[k]) k = par[k - 1];
    if (pat[i] == pat[k]) k++;
    par[i] = k;
  }
  return;
}
int dp[110][110][110], len1, len2, M;
int dp_kmp[110][210];
int kmp_solve(int len, int now) {
  int &ret = dp_kmp[len][now];
  if (ret != -1) return ret;
  while (len > 0 && pat[len] != now) len = par[len - 1];
  if (pat[len] == now) len++;
  return ret = len;
}
int solve(int indx1, int indx2, int match) {
  int &ret = dp[indx1][indx2][match];
  if (~ret) return ret;
  if (indx1 == len1 || indx2 == len2) return ret = 0;
  ret = solve(indx1 + 1, indx2, match);
  ret = max(ret, solve(indx1, indx2 + 1, match));
  if (s1[indx1] == s2[indx2]) {
    match = kmp_solve(match, s1[indx1]);
    if (match < M) ret = max(ret, 1 + solve(indx1 + 1, indx2 + 1, match));
  }
  return ret;
}
void path(int indx1, int indx2, int match) {
  if (indx1 >= len1 || indx2 >= len2) {
    printf("\n");
    return;
  }
  int k = dp[indx1][indx2][match];
  if (k == dp[indx1 + 1][indx2][match]) return path(indx1 + 1, indx2, match);
  if (k == dp[indx1][indx2 + 1][match]) return path(indx1, indx2 + 1, match);
  printf("%c", s1[indx1]);
  return path(indx1 + 1, indx2 + 1, kmp_solve(match, s1[indx1]));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int k;
  while (cin >> s1 >> s2 >> pat) {
    len1 = (int)s1.size();
    len2 = (int)s2.size();
    M = (int)pat.size();
    memset(dp, -1, sizeof(dp));
    memset(dp_kmp, -1, sizeof(dp_kmp));
    pre_process();
    k = solve(0, 0, 0);
    if (!k)
      PR(k);
    else
      path(0, 0, 0);
  }
  return 0;
}
