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 l1, l2, l3, dp[105][105][105];
char s1[105], s2[105], s3[105];
int dfs(int n1, int n2, int n3) {
  int ret = -1000000000;
  if (n3 == l3) return dp[n1][n2][n3] = -1000000000;
  if (n1 > l1 || n2 > l2) return dp[n1][n2][n3] = 0;
  if (~dp[n1][n2][n3]) return dp[n1][n2][n3];
  if (s1[n1] == s2[n2]) {
    if (s3[n3 + 1] == s1[n1]) {
      ret = max(dfs(n1 + 1, n2 + 1, n3 + 1) + 1, ret);
      if (s3[1] == s1[n1]) {
        int res = dfs(n1 + 1, n2 + 1, 1) + 1;
        ret = min(ret, res);
      }
    } else {
      int go = (s1[n1] == s3[1]);
      ret = max(dfs(n1 + 1, n2 + 1, go) + 1, ret);
    }
  }
  ret = max(ret, max(dfs(n1 + 1, n2, n3), dfs(n1, n2 + 1, n3)));
  return dp[n1][n2][n3] = ret;
}
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%s %s %s", s1 + 1, s2 + 1, s3 + 1);
  l1 = strlen(s1 + 1);
  l2 = strlen(s2 + 1);
  l3 = strlen(s3 + 1);
  dfs(1, 1, 0);
  int n1 = 1, n2 = 1, n3 = 0;
  while (n1 <= l1 && n2 <= l2) {
    if (s1[n1] == s2[n2]) {
      if (s3[n3 + 1] == s1[n1]) {
        if (dp[n1][n2][n3] == dp[n1 + 1][n2 + 1][n3 + 1] + 1) {
          printf("%c", s1[n1]);
          n1++;
          n2++;
          n3++;
          continue;
        }
        if (s3[1] == s1[n1]) {
          if (dp[n1][n2][n3] == dp[n1 + 1][n2 + 1][1]) {
            printf("%c", s1[n1]);
            n1++;
            n2++;
            n3 = 1;
            continue;
          }
        }
      } else {
        int go = (s1[n1] == s3[1]);
        if (dp[n1][n2][n3] == dp[n1 + 1][n2 + 1][go] + 1) {
          printf("%c", s1[n1]);
          n1++;
          n2++;
          n3 = go;
          continue;
        }
      }
    }
    if (dp[n1][n2][n3] == dp[n1 + 1][n2][n3]) {
      n1++;
      continue;
    }
    if (dp[n1][n2][n3] == dp[n1][n2 + 1][n3]) {
      n2++;
      continue;
    }
  }
  if (!dp[1][1][0]) printf("0");
}