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;
long long MOD = 1000000007;
long long POW(long long a, long long b, long long MMM = MOD) {
  long long ret = 1;
  for (; b; b >>= 1, a = (a * a) % MMM)
    if (b & 1) ret = (ret * a) % MMM;
  return ret;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) {
  if (a == 0 || b == 0) return a + b;
  return a * (b / gcd(a, b));
}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int ddx[] = {0, 0, 1, 1, 1, -1, -1, -1}, ddy[] = {1, -1, 1, 0, -1, 1, 0, -1};
int n, m, l;
char a[101], b[101], c[101];
int pi[100];
int d[100][100][100];
int go(int N, int M, int L) {
  if (L == l) return -987654321;
  if (N == n || M == m) return 0;
  int &ret = d[N][M][L];
  if (ret != -1) return ret;
  ret = 0;
  ret = max(ret, go(N + 1, M, L));
  ret = max(ret, go(N, M + 1, L));
  if (a[N] == b[M]) {
    if (a[N] == c[L])
      ret = max(ret, 1 + go(N + 1, M + 1, L + 1));
    else {
      while (L != 0 && a[N] != c[L]) L = pi[L - 1];
      if (a[N] == c[L])
        ret = max(ret, 1 + go(N + 1, M + 1, L + 1));
      else
        ret = max(ret, 1 + go(N + 1, M + 1, L));
    }
  }
  return ret;
}
void track(int N, int M, int L) {
  if (N == n || M == m) return;
  int t1 = go(N + 1, M, L);
  int t2 = go(N, M + 1, L);
  int t3 = -987654321, t4 = -987654321, t5 = -987654321;
  int tl = L;
  if (a[N] == b[M]) {
    if (a[N] == c[L])
      t3 = 1 + go(N + 1, M + 1, L + 1);
    else {
      while (tl != 0 && a[N] != c[tl]) tl = pi[tl - 1];
      if (a[N] == c[tl])
        t4 = 1 + go(N + 1, M + 1, tl + 1);
      else
        t5 = 1 + go(N + 1, M + 1, tl);
    }
  }
  int MAX = max({t1, t2, t3, t4, t5});
  if (t1 == MAX)
    track(N + 1, M, L);
  else if (t2 == MAX)
    track(N, M + 1, L);
  else if (t3 == MAX) {
    printf("%c", a[N]);
    track(N + 1, M + 1, L + 1);
  } else if (t4 == MAX) {
    printf("%c", a[N]);
    track(N + 1, M + 1, tl + 1);
  } else {
    printf("%c", a[N]);
    track(N + 1, M + 1, tl);
  }
}
int main() {
  memset(d, -1, sizeof(d));
  ;
  scanf("%s%s%s", a, b, c);
  n = strlen(a), m = strlen(b), l = strlen(c);
  for (int i = 1, j = 0; i < l; i++) {
    while (j > 0 && c[i] != c[j]) j = pi[j - 1];
    if (c[i] == c[j]) pi[i] = ++j;
  }
  int t = go(0, 0, 0);
  if (t == 0) return !printf("0");
  track(0, 0, 0);
}