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;
char str1[110], str2[110], virus[110];
int dp[110][110][110], fail[110], path[110][110][110][2];
void get_fail(char* str) {
  fail[0] = 0;
  fail[1] = 0;
  int j;
  for (int i = 1; i < (int)strlen(virus); ++i) {
    j = fail[i];
    while (j && str[i] != str[j]) j = fail[j];
    fail[i + 1] = str[i] == str[j] ? j + 1 : 0;
  }
}
void print(int x1, int x2, int t) {
  if (path[x1][x2][t][0] == 1) {
    print(x1 - 1, x2 - 1, path[x1][x2][t][1]);
    printf("%c", str1[x1 - 1]);
  } else if (path[x1][x2][t][0] == 3) {
    print(x1 - 1, x2, path[x1][x2][t][1]);
  } else if (path[x1][x2][t][0] == 2) {
    print(x1, x2 - 1, path[x1][x2][t][1]);
  }
}
int main(void) {
  memset(path, -1, sizeof(path));
  scanf("%s %s %s", str1, str2, virus);
  int l1 = (int)strlen(str1);
  int l2 = (int)strlen(str2);
  int l3 = (int)strlen(virus);
  get_fail(virus);
  for (int i = 1; i <= l1; ++i)
    for (int j = 1; j <= l2; ++j)
      for (int k = 0; k < l3; ++k) {
        if (str1[i - 1] == str2[j - 1]) {
          if (str1[i - 1] == virus[k]) {
            if (dp[i - 1][j - 1][k] + 1 > dp[i][j][k + 1]) {
              dp[i][j][k + 1] = dp[i - 1][j - 1][k] + 1;
              path[i][j][k + 1][0] = 1;
              path[i][j][k + 1][1] = k;
            }
            dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i - 1][j - 1][k] + 1);
          } else {
            int t = fail[k];
            while (t && virus[t] != str1[i - 1]) t = fail[t];
            if (virus[t] == str1[i - 1]) t++;
            if (dp[i - 1][j - 1][k] + 1 > dp[i][j][t]) {
              dp[i][j][t] = dp[i - 1][j - 1][k] + 1;
              path[i][j][t][0] = 1;
              path[i][j][t][1] = k;
            }
          }
        }
        if (dp[i][j - 1][k] > dp[i][j][k]) {
          dp[i][j][k] = dp[i][j - 1][k];
          path[i][j][k][0] = 2;
          path[i][j][k][1] = k;
        }
        if (dp[i - 1][j][k] > dp[i][j][k]) {
          dp[i][j][k] = dp[i - 1][j][k];
          path[i][j][k][0] = 3;
          path[i][j][k][1] = k;
        }
      }
  int ma = 0, k = -1;
  for (int i = 0; i < l3; ++i)
    if (dp[l1][l2][i] > ma) {
      ma = dp[l1][l2][i];
      k = i;
    }
  if (k != -1) {
    print(l1, l2, k);
    putchar(10);
  } else
    printf("%d\n", ma);
  return 0;
}