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 ans1, ans2, ans3, maxs;
int f[105];
int dp[105][105][105];
int p1[105][105][105], p2[105][105][105], p3[105][105][105];
char s1[105], s2[105], s3[105];
char s4[105];
void Fail() {
  int m = strlen(s3);
  f[0] = 0;
  f[1] = 0;
  for (int i = 1; i < m; i++) {
    int j = f[i];
    while (j && s3[i] != s3[j]) j = f[j];
    f[i + 1] = s3[i] == s3[j] ? j + 1 : 0;
  }
  return;
}
int main() {
  while (scanf("%s %s %s", &s1, &s2, &s3) != EOF) {
    int len1 = strlen(s1);
    int len2 = strlen(s2);
    int len3 = strlen(s3);
    Fail();
    maxs = 0;
    for (int i = 0; i <= len1; i++)
      for (int j = 0; j <= len3; j++) dp[i][0][j] = 0;
    for (int i = 0; i <= len2; i++)
      for (int j = 0; j <= len3; j++) dp[0][i][j] = 0;
    for (int i = 1; i <= len1; i++)
      for (int j = 1; j <= len2; j++) {
        if (i == len1 && j == len2) {
          int cas = 0;
        }
        for (int k = 0; k < len3; k++) {
          dp[i][j][k] = dp[i - 1][j][k];
          p1[i][j][k] = -1;
          p2[i][j][k] = 0;
          if (dp[i][j][k] < dp[i][j - 1][k]) {
            dp[i][j][k] = dp[i][j - 1][k];
            p1[i][j][k] = 0;
            p2[i][j][k] = -1;
          }
          p3[i][j][k] = k;
        }
        int t1;
        if (s1[i - 1] == s2[j - 1])
          for (int k = 0; k < len3; k++) {
            if (s3[k] == s1[i - 1])
              t1 = k + 1;
            else {
              t1 = f[k];
              while (t1 && s3[t1] != s1[i - 1]) t1 = f[t1];
              if (s3[t1] == s1[i - 1]) t1++;
            }
            if (t1 < len3 && dp[i][j][t1] < dp[i - 1][j - 1][k] + 1) {
              dp[i][j][t1] = dp[i - 1][j - 1][k] + 1;
              p1[i][j][t1] = -1;
              p2[i][j][t1] = -1;
              p3[i][j][t1] = k;
            }
          }
        for (int k = 0; k < len3; k++)
          if (maxs < dp[i][j][k]) {
            maxs = dp[i][j][k];
            ans1 = i, ans2 = j;
            ans3 = k;
          }
      }
    if (maxs == 0)
      printf("0\n");
    else {
      int tmp = maxs - 1;
      while (ans1 > 0 && ans2 > 0) {
        int u1 = p1[ans1][ans2][ans3];
        int u2 = p2[ans1][ans2][ans3];
        int u3 = p3[ans1][ans2][ans3];
        if (u1 == -1 && u2 == -1) {
          s4[tmp--] = s1[ans1 - 1];
        }
        ans1 += u1;
        ans2 += u2;
        ans3 = u3;
      }
      for (int i = 0; i < maxs; i++) printf("%c", s4[i]);
      printf("\n");
    }
  }
  return 0;
}