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 maxn = 110;
int n, m, p, f[maxn][maxn][maxn], fail[maxn];
char s1[maxn], s2[maxn], s3[maxn];
bool g[maxn][maxn][maxn];
struct rec {
  int x, y, z;
  rec() {}
  rec(int a, int b, int c) {
    x = a;
    y = b;
    z = c;
  }
} pre[maxn][maxn][maxn];
void back(int x, int y, int z) {
  if (!x && !y) return;
  int xx = pre[x][y][z].x;
  int yy = pre[x][y][z].y;
  int zz = pre[x][y][z].z;
  back(xx, yy, zz);
  if (xx + 1 == x && yy + 1 == y) printf("%c", s1[x]);
}
int main() {
  scanf("%s", s1 + 1);
  scanf("%s", s2 + 1);
  scanf("%s", s3 + 1);
  n = strlen(s1 + 1);
  m = strlen(s2 + 1);
  p = strlen(s3 + 1);
  for (int a = 1, b = 0; a < p; a++) {
    while (b && s3[b + 1] != s3[a + 1]) b = fail[b];
    if (s3[b + 1] == s3[a + 1]) b++;
    fail[a + 1] = b;
  }
  g[0][0][0] = true;
  for (int a = 0; a <= n; a++)
    for (int b = 0; b <= m; b++)
      for (int c = 0; c < p; c++)
        if (g[a][b][c]) {
          if (f[a + 1][b][c] <= f[a][b][c]) {
            g[a + 1][b][c] = true;
            pre[a + 1][b][c] = rec(a, b, c);
            f[a + 1][b][c] = f[a][b][c];
          }
          if (f[a][b + 1][c] <= f[a][b][c]) {
            g[a][b + 1][c] = true;
            pre[a][b + 1][c] = rec(a, b, c);
            f[a][b + 1][c] = f[a][b][c];
          }
          if (s1[a + 1] == s2[b + 1]) {
            int x = c;
            while (x && s3[x + 1] != s1[a + 1]) x = fail[x];
            if (s3[x + 1] == s1[a + 1])
              x++;
            else
              x = 0;
            if (f[a + 1][b + 1][x] <= f[a][b][c] + 1) {
              g[a + 1][b + 1][x] = true;
              pre[a + 1][b + 1][x] = rec(a, b, c);
              f[a + 1][b + 1][x] = f[a][b][c] + 1;
            }
          }
        }
  int ans = 0;
  int x;
  for (int a = 0; a < p; a++)
    if (f[n][m][a] > ans) {
      ans = f[n][m][a];
      x = a;
    }
  if (ans)
    back(n, m, x);
  else
    printf("0\n");
  return 0;
}