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;
const int maxn = 105;
const int inf = 0x3f3f3f3f;
char a[maxn], b[maxn], c[maxn];
int dp[maxn][maxn][maxn], Next[maxn], alen, blen, clen;
void SetNext() {
  int i = Next[0] = -1, j = 0;
  while (c[j] != '\0') {
    if (i == -1 || c[i] == c[j]) {
      i++, j++;
      if (c[i] == c[j])
        Next[j] = Next[i];
      else
        Next[j] = i;
    } else
      i = Next[i];
  }
}
int dfs(int i, int j, int k) {
  if (k >= clen) return -inf;
  if (i >= alen || j >= blen) return 0;
  if (dp[i][j][k] != -1) return dp[i][j][k];
  int m = k, ans = 0;
  if (a[i] == b[j]) {
    while (a[i] != c[m] && m >= 0) m = Next[m];
    ans = max(ans, 1 + dfs(i + 1, j + 1, m + 1));
  }
  ans = max(ans, dfs(i, j + 1, k));
  ans = max(ans, dfs(i + 1, j, k));
  return dp[i][j][k] = ans;
}
void BackPrint(int i, int j, int k) {
  if (i >= alen || j >= blen || k >= clen) return;
  if (a[i] == b[j]) {
    int m = k;
    while (a[i] != c[m] && m >= 0) m = Next[m];
    if (dp[i][j][k] == dfs(i + 1, j + 1, m + 1) + 1) {
      printf("%c", a[i]);
      BackPrint(i + 1, j + 1, m + 1);
      return;
    }
  }
  if (dfs(i, j, k) == dfs(i, j + 1, k))
    BackPrint(i, j + 1, k);
  else if (dfs(i, j, k) == dfs(i + 1, j, k))
    BackPrint(i + 1, j, k);
}
int main() {
  scanf("%s%s%s", a, b, c);
  alen = strlen(a), blen = strlen(b), clen = strlen(c);
  SetNext();
  memset(dp, -1, sizeof(dp));
  if (dfs(0, 0, 0) != 0)
    BackPrint(0, 0, 0);
  else
    printf("0\n");
  return 0;
}