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[205][205][205], ans, len;
int Next[205];
char s1[1005], s2[1005], v[1005];
struct node {
  int n;
  int m;
  int k;
} pre[105][105][105];
void get_next() {
  int l = strlen(v);
  Next[0] = -1;
  int k = -1, j = 0, i;
  while (j < l) {
    if (k == -1 || v[j] == v[k]) {
      k++;
      j++;
      Next[j] = k;
    } else
      k = Next[k];
  }
}
int match_len(int i, char c) {
  if (i == len) puts("error");
  while (i >= 0) {
    if (v[i] == c) {
      break;
    } else
      i = Next[i];
  }
  return i + 1;
}
int dfs(int n, int m, int k) {
  if (dp[n][m][k] == -1) {
    if (n == 0 || m == 0 || k > n || k > m) {
      return dp[n][m][k] = 0;
    }
    if (dfs(n, m - 1, k) > dfs(n - 1, m, k)) {
      dp[n][m][k] = dfs(n, m - 1, k);
      pre[n][m][k].n = n;
      pre[n][m][k].m = m - 1;
      pre[n][m][k].k = k;
    } else {
      dp[n][m][k] = dfs(n - 1, m, k);
      pre[n][m][k].n = n - 1;
      pre[n][m][k].m = m;
      pre[n][m][k].k = k;
    }
    if (s1[n - 1] == s2[m - 1]) {
      int i;
      for (i = max(0, k - 1); i < len; i++) {
        if (match_len(i, s1[n - 1]) == k &&
            dp[n][m][k] < dfs(n - 1, m - 1, i) + 1) {
          dp[n][m][k] = dfs(n - 1, m - 1, i) + 1;
          pre[n][m][k].n = n - 1;
          pre[n][m][k].m = m - 1;
          pre[n][m][k].k = i;
        }
      }
    }
    if (dp[n][m][k] < k) {
    }
  }
  return dp[n][m][k];
}
void putway(int n, int m, int k) {
  if (dp[n][m][k] == 0) return;
  node temp = pre[n][m][k];
  putway(temp.n, temp.m, temp.k);
  if (dp[n][m][k] != dp[temp.n][temp.m][temp.k]) {
    printf("%c", s1[n - 1]);
  }
}
int main() {
  int i, j, n, m;
  memset(dp, -1, sizeof(dp));
  dp[0][0][0] = 0;
  scanf("%s%s%s", s1, s2, v);
  n = strlen(s1);
  m = strlen(s2);
  len = strlen(v);
  get_next();
  ans = 0;
  j = -1;
  for (i = 0; i < len; i++) {
    if (dfs(n, m, i) > ans) {
      j = i;
      ans = dfs(n, m, i);
    }
  }
  if (ans == 0) {
    puts("0");
  } else {
    putway(n, m, j);
  }
  return 0;
}