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;
string A, B;
string virus;
int d[105][105][105];
int to1[105][105][105];
int to2[105][105][105];
int to3[105][105][105];
int pi[105];
int go(int a, int b, int v);
void check(int &r, int a, int b, int v, int a2, int b2, int v2, int ck) {
  int tmp = go(a2, b2, v2) + ck;
  if (r < tmp) {
    r = tmp;
    to1[a][b][v] = a2;
    to2[a][b][v] = b2;
    to3[a][b][v] = v2;
  }
}
int nxt(int x, char k) {
  while (x >= 0) {
    if (virus[x] == k) return x + 1;
    x = pi[x];
  }
  return 0;
}
int go(int a, int b, int v) {
  if (v == virus.size()) return -(1 << 30);
  if (a == A.size() || b == B.size()) return 0;
  int &r = d[a][b][v];
  if (r != -1) return r;
  r = 0;
  check(r, a, b, v, a, b + 1, v, 0);
  check(r, a, b, v, a + 1, b, v, 0);
  if (A[a] == B[b]) {
    check(r, a, b, v, a + 1, b + 1, nxt(v, A[a]), 1);
  }
  return r;
}
void print(int a, int b, int v) {
  if (a == A.size() || b == B.size()) return;
  if (a == -1) return;
  int a2 = to1[a][b][v];
  int b2 = to2[a][b][v];
  int v2 = to3[a][b][v];
  if (a2 == a + 1 && b2 == b + 1) cout << A[a];
  print(a2, b2, v2);
}
void find_pi() {
  int i = 0, j = -1;
  pi[0] = -1;
  while (i < virus.size()) {
    if (j == -1 || virus[i] == virus[j]) {
      i++;
      j++;
      pi[i] = j;
    } else
      j = pi[j];
  }
}
int main() {
  cin >> A >> B >> virus;
  memset(d, -1, sizeof(d));
  memset(to1, -1, sizeof(d));
  memset(to2, -1, sizeof(d));
  memset(to3, -1, sizeof(d));
  find_pi();
  int ans = go(0, 0, 0);
  if (ans == 0)
    cout << "0" << endl;
  else {
    print(0, 0, 0);
  }
}