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