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;
template <class T>
inline T bigmod(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T bpow(T p, T e) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
int toInt(string s) {
  int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int toLlint(string s) {
  long long int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int ls[105];
string a, b, c;
void kmp() {
  int k = 0;
  ls[0] = 0;
  int i = 1;
  while (i < c.size()) {
    if (c[i] == c[k]) {
      k++;
      ls[i] = k;
      i++;
    } else {
      if (k == 0) {
        ls[i] = 0;
        i++;
      } else {
        k = ls[k - 1];
      }
    }
  }
}
int ln1, ln2, ln3;
bool bl[105][105][105];
int p[105][105][105], r[105][105][105];
int dp(int i, int j, int k) {
  if (k == ln3) return -1000000;
  if (i == ln1 || j == ln2) {
    return 0;
  }
  int &pr = p[i][j][k];
  int &rs = r[i][j][k];
  if (bl[i][j][k]) return pr;
  bl[i][j][k] = 1;
  pr = 0;
  int q;
  q = dp(i + 1, j, k);
  if (q > pr) {
    pr = q;
    rs = 0;
  }
  q = dp(i, j + 1, k);
  if (q > pr) {
    pr = q;
    rs = 1;
  }
  if (a[i] == b[j]) {
    while (k > 0 && c[k] != a[i]) k = ls[k - 1];
    if (a[i] == c[k]) {
      q = dp(i + 1, j + 1, k + 1) + 1;
      if (q > pr) {
        pr = q;
        rs = -(k + 1);
      }
    } else {
      q = dp(i + 1, j + 1, 0) + 1;
      if (q > pr) {
        pr = q;
        rs = 2;
      }
    }
  }
  return pr;
}
void prnt(int i, int j, int k) {
  if (i == ln1 || j == ln2) {
    return;
  }
  if (r[i][j][k] == 0) {
    prnt(i + 1, j, k);
  } else if (r[i][j][k] == 1)
    prnt(i, j + 1, k);
  else if (r[i][j][k] == 2) {
    printf("%c", a[i]);
    prnt(i + 1, j + 1, 0);
  } else {
    printf("%c", a[i]);
    prnt(i + 1, j + 1, -r[i][j][k]);
  }
}
int main() {
  int cs = 1, t, i, j, k;
  while (cin >> a >> b >> c) {
    ln1 = a.size();
    ln2 = b.size();
    ln3 = c.size();
    kmp();
    k = dp(0, 0, 0);
    if (k == 0)
      printf("0\n");
    else {
      prnt(0, 0, 0);
      printf("\n");
    }
  }
  return 0;
}