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 N = 105;
char A[N], B[N];
char buf[N];
const int E = 26;
int go[N][E];
const long long P = 4243;
long long PP[N];
long long H[N];
inline long long get(int i, int j) { return H[j] - H[i] * PP[j - i]; }
char D[N][N][N];
int prv[N][N][N];
bool add[N][N][N];
int a, b, n;
inline void relax(int i1, int j1, int v1, int i2, int j2, int v2, int q) {
  if (D[i1][j1][v1] < D[i2][j2][v2] + q)
    D[i1][j1][v1] = D[i2][j2][v2] + q,
    prv[i1][j1][v1] = i2 * N * N + j2 * N + v2, add[i1][j1][v1] = q;
}
char str[N];
int main() {
  gets(A);
  gets(B);
  gets(buf);
  a = strlen(A);
  b = strlen(B);
  n = strlen(buf);
  PP[0] = 1;
  for (int i = 0; i < n; i++)
    PP[i + 1] = PP[i] * P, H[i + 1] = H[i] * P + buf[i] - 'A';
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26; j++) {
      go[i][j] = 0;
      for (int l = i + 1; l >= 1; l--) {
        long long h2 = get(i - l + 1, i) * P + j;
        long long h1 = get(0, l);
        if (h1 == h2) {
          go[i][j] = l;
          break;
        }
      }
    }
  }
  memset(D, -1, sizeof(D));
  D[0][0][0] = 0;
  for (int i = 0; i <= a; i++)
    for (int j = 0; j <= b; j++)
      for (int v = 0; v < n; v++) {
        if (D[i][j][v] == -1) continue;
        if (i != a && j != b && A[i] == B[j])
          relax(i + 1, j + 1, go[v][A[i] - 'A'], i, j, v, 1);
        if (i != a) relax(i + 1, j, v, i, j, v, 0);
        if (j != b) relax(i, j + 1, v, i, j, v, 0);
      }
  int ans = -1;
  int ansp = -1;
  for (int v = 0; v < n; v++)
    if (ans < D[a][b][v]) ans = D[a][b][v], ansp = v;
  fprintf(stderr, "%d %d\n", ans, ansp);
  int cur = a * N * N + b * N + ansp;
  int pt = 0;
  while (true) {
    int v = cur % N;
    cur /= N;
    int j = cur % N;
    cur /= N;
    int i = cur;
    if (i == 0 && j == 0) break;
    if (add[i][j][v]) str[ans - (++pt)] = A[i - 1];
    int pcur = prv[i][j][v];
    cur = pcur;
  }
  if (!ans)
    puts("0");
  else
    puts(str);
  return 0;
}