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;
struct eugin {
  int x, y, z;
  char v;
};
char s[3][110];
int l[3];
int f[110][110][110];
int p[110][26];
eugin path[110][110][110];
int check(int x, int y, int i) {
  if (s[0][i] != 'A' + y) return false;
  i--;
  x--;
  while (i >= 0) {
    if (s[0][i] != s[0][x]) return false;
    i--;
    x--;
  }
  return true;
}
int calc(int x, int y) {
  int ret = 0;
  for (int i = l[0]; i >= 1; i--)
    if (x >= i - 1) {
      if (check(x, y, i - 1)) {
        ret = i;
        break;
      }
    }
  return ret;
}
void init() {
  int i, j;
  for (i = 0; i < l[0]; i++)
    for (j = 0; j < 26; j++) p[i][j] = calc(i, j);
  memset(f, -1, sizeof(f));
  memset(path, -1, sizeof(path));
}
int F(int x, int y, int z) {
  if (z >= l[0]) return -22222222;
  if (f[x][y][z] != -1) return f[x][y][z];
  if (x >= l[1] || y >= l[2]) {
    f[x][y][z] = 0;
    return 0;
  }
  int ret = -22222222;
  eugin temp;
  int t = F(x + 1, y, z);
  if (t > ret) {
    ret = t;
    temp.x = x + 1;
    temp.y = y;
    temp.z = z;
    temp.v = -1;
  }
  t = F(x, y + 1, z);
  if (t > ret) {
    ret = t;
    temp.x = x;
    temp.y = y + 1;
    temp.z = z;
    temp.v = -1;
  }
  if (s[1][x] == s[2][y]) t = F(x + 1, y + 1, p[z][s[1][x] - 'A']) + 1;
  if (t > ret) {
    ret = t;
    temp.x = x + 1;
    temp.y = y + 1;
    temp.z = p[z][s[1][x] - 'A'];
    temp.v = s[1][x];
  }
  path[x][y][z] = temp;
  f[x][y][z] = ret;
  return ret;
}
int main() {
  int ans, i, x, y, z;
  char out[110];
  scanf("%s", s[1]);
  l[1] = strlen(s[1]);
  scanf("%s", s[2]);
  l[2] = strlen(s[2]);
  scanf("%s", s[0]);
  l[0] = strlen(s[0]);
  init();
  ans = F(0, 0, 0);
  if (ans == 0)
    printf("0\n");
  else {
    eugin t;
    t.x = t.y = t.z = i = 0;
    while (path[t.x][t.y][t.z].x != -1) {
      if (path[t.x][t.y][t.z].v > 0) {
        out[i] = path[t.x][t.y][t.z].v;
        i++;
      }
      x = path[t.x][t.y][t.z].x;
      y = path[t.x][t.y][t.z].y;
      z = path[t.x][t.y][t.z].z;
      t.x = x;
      t.y = y;
      t.z = z;
    }
    out[i] = 0;
    printf("%s\n", out);
  }
  return 0;
}