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;
int n, m, k;
char a[105];
char b[105];
char c[105];
int dp2[105][26];
int go[105][105][105];
int dp[105][105][105];
bool mark[105][105][105];
int g(int last, char cc) {
  char s[105];
  for (int i = 1; i <= last; i++) s[i] = c[i];
  s[last + 1] = cc;
  for (int t = last; t >= 1; t--) {
    bool ok = true;
    for (int i = last + 1, j = t; j >= 1 && ok; i--, j--)
      if (s[i] != c[j]) ok = false;
    if (!ok) continue;
    return t;
  }
  return 0;
}
int f(int x, int y, int z) {
  if (z == k) return -1;
  if (x == n + 1 || y == m + 1) return 0;
  if (mark[x][y][z]) return dp[x][y][z];
  dp[x][y][z] = -1;
  mark[x][y][z] = true;
  int tmp;
  if (a[x] == b[y]) {
    int ok = (a[x] == c[z + 1]);
    int tmp2 = 0;
    if (ok)
      tmp = f(x + 1, y + 1, z + 1);
    else {
      tmp2 = dp2[z][a[x] - 'A'];
      tmp = f(x + 1, y + 1, tmp2);
    }
    tmp++;
    if (tmp && tmp > dp[x][y][z]) {
      dp[x][y][z] = tmp;
      go[x][y][z] = -tmp2;
    }
  }
  tmp = f(x + 1, y, z);
  if (tmp > dp[x][y][z]) {
    dp[x][y][z] = tmp;
    go[x][y][z] = 1;
  }
  tmp = f(x, y + 1, z);
  if (tmp > dp[x][y][z]) {
    dp[x][y][z] = tmp;
    go[x][y][z] = 2;
  }
  return dp[x][y][z];
}
int main() {
  scanf("%s%s%s", a + 1, b + 1, c + 1);
  n = strlen(a + 1);
  m = strlen(b + 1);
  k = strlen(c + 1);
  for (int i = 0; i < k; i++)
    for (int j = 0; j < 26; j++) dp2[i][j] = g(i, j + 'A');
  int tmp = f(1, 1, 0);
  if (tmp <= 0) {
    printf("0\n");
    exit(0);
  }
  int x = 1, y = 1, z = 0;
  while (x != n + 1 && y != m + 1) {
    if (go[x][y][z] == 1)
      x++;
    else if (go[x][y][z] == 2)
      y++;
    else {
      printf("%c", a[x]);
      if (a[x] == c[z + 1])
        z++;
      else
        z = -go[x][y][z];
      x++, y++;
    }
  }
  printf("\n");
  return 0;
}