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>
char S1[121], S2[121], V[121];
int D[121][121][121], F[121], rx[121][121][121], ry[121][121][121],
    rz[121][121][121], rpl[121][121][121], ansn = 0;
char ans[121];
void inst(int x, int y, int z, int i, int j, int k, int pl) {
  D[x][y][z] = D[i][j][k] + pl;
  rx[x][y][z] = i;
  ry[x][y][z] = j;
  rz[x][y][z] = k;
  rpl[x][y][z] = pl;
}
int main() {
  int n, m, k, i, j, p;
  scanf("%s%s%s", S1 + 1, S2 + 1, V + 1);
  n = strlen(S1 + 1), m = strlen(S2 + 1), k = strlen(V + 1);
  for (i = 2; i <= k; i++) {
    int now = F[i - 1];
    while (1) {
      if (V[now + 1] == V[i]) {
        F[i] = now + 1;
        break;
      }
      if (now == 0) break;
      now = F[now];
    }
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      for (p = 0; p <= k; p++) {
        if (D[i][j - 1][p] > D[i - 1][j][p])
          inst(i, j, p, i, j - 1, p, 0);
        else
          inst(i, j, p, i - 1, j, p, 0);
      }
      if (S1[i] == S2[j]) {
        for (p = 0; p < k; p++) {
          if (p && !D[i - 1][j - 1][p]) continue;
          int now = p;
          while (1) {
            if (S1[i] == V[now + 1]) {
              now++;
              break;
            }
            if (now == 0) break;
            now = F[now];
          }
          if (D[i][j][now] < D[i - 1][j - 1][p] + 1)
            inst(i, j, now, i - 1, j - 1, p, 1);
        }
      }
    }
  int mx = 0, nx, ny, nz;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      for (p = 0; p < k; p++) {
        if (mx < D[i][j][p]) mx = D[i][j][p], nx = i, ny = j, nz = p;
      }
  if (mx == 0) {
    printf("0");
    return 0;
  }
  while (nx > 0 && ny > 0) {
    int x, y, z;
    x = rx[nx][ny][nz];
    y = ry[nx][ny][nz];
    z = rz[nx][ny][nz];
    if (rpl[nx][ny][nz]) ans[ansn++] = S1[nx];
    nx = x;
    ny = y;
    nz = z;
  }
  for (i = ansn - 1; i >= 0; i--) printf("%c", ans[i]);
  return 0;
}