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 dp[105][105][105];
char a[105], b[105], c[105], tmp[105];
int n1, n2, n3, ans;
char f[105][105][105][105], res[105];
int main() {
  scanf("%s", a + 1);
  scanf("%s", b + 1);
  scanf("%s", c + 1);
  n1 = strlen(a + 1);
  n2 = strlen(b + 1);
  n3 = strlen(c + 1);
  for (int i = 0; i <= n1; i++) {
    for (int j = 0; j <= n2; j++) {
      for (int k = 0; k < n3; k++) {
        if (ans < dp[i][j][k]) {
          ans = dp[i][j][k];
          strcpy(res, f[i][j][k]);
        }
        if (i < n1 && dp[i + 1][j][k] < dp[i][j][k]) {
          dp[i + 1][j][k] = dp[i][j][k];
          strcpy(f[i + 1][j][k], f[i][j][k]);
        }
        if (j < n2 && dp[i][j + 1][k] < dp[i][j][k]) {
          dp[i][j + 1][k] = dp[i][j][k];
          strcpy(f[i][j + 1][k], f[i][j][k]);
        }
        if (i < n1 && j < n2) {
          if (a[i + 1] == b[j + 1]) {
            strcpy(tmp, f[i][j][k]);
            int len = dp[i][j][k] + 1;
            tmp[len - 1] = a[i + 1];
            tmp[len] = '\0';
            for (int l = min(len, n3); l >= 0; l--) {
              bool out = true;
              for (int p = 0; p < l; p++) {
                if (c[p + 1] != tmp[len - l + p]) {
                  out = false;
                  break;
                }
              }
              if (out) {
                if (len > dp[i + 1][j + 1][l]) {
                  dp[i + 1][j + 1][l] = len;
                  strcpy(f[i + 1][j + 1][l], tmp);
                }
                break;
              }
            }
          }
          if (dp[i + 1][j + 1][k] < dp[i][j][k]) {
            dp[i + 1][j + 1][k] = dp[i][j][k];
            strcpy(f[i + 1][j + 1][k], f[i][j][k]);
          }
        }
      }
    }
  }
  if (ans)
    puts(res);
  else
    puts("0");
  return 0;
}