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 = 1000100;
const int INF = 1e9 + 10;
char a[maxn], b[maxn], c[maxn];
int dp[120][120][120];
int an, bn, cn;
int f[maxn];
void getFail(char *c, int n) {
  f[n] = f[n - 1] = n;
  for (int i = n - 1; i > 1; i--) {
    int j = f[i];
    while (j != n && c[i] != c[j]) j = f[j];
    f[i - 1] = c[i] == c[j] ? j - 1 : n;
  }
}
int dfs(int i, int j, int k) {
  int &res = dp[i][j][k];
  if (~res) return res;
  if (k == 0) return res = -INF;
  if (i < 1 || j < 1) return res = 0;
  res = 0;
  if (a[i] == b[j]) {
    int kt = k;
    while (kt != cn && a[i] != c[kt]) kt = f[kt];
    int tmp = 0;
    if (a[i] == c[kt])
      tmp = dfs(i - 1, j - 1, kt - 1) + 1;
    else
      tmp = dfs(i - 1, j - 1, kt) + 1;
    res = max(tmp, max(dfs(i - 1, j, k), dfs(i, j - 1, k)));
  } else
    res = max(dfs(i - 1, j, k), dfs(i, j - 1, k));
  return res;
}
void Print(int i, int j, int k) {
  int res = dp[i][j][k];
  if (i < 1 || j < 1) return;
  if (a[i] == b[j]) {
    int x = dp[i - 1][j][k], y = dp[i][j - 1][k];
    int kt = k;
    while (kt != cn && a[i] != c[kt]) kt = f[kt];
    int tmp = 0;
    if (a[i] == c[kt])
      tmp = dp[i - 1][j - 1][kt - 1] + 1;
    else
      tmp = dp[i - 1][j - 1][kt] + 1;
    if (res == tmp) {
      if (a[i] == c[kt])
        Print(i - 1, j - 1, kt - 1);
      else
        Print(i - 1, j - 1, kt);
      printf("%c", a[i]);
    } else {
      if (tmp == x)
        Print(i - 1, j, k);
      else
        Print(i, j - 1, k);
    }
  } else {
    if (res == dp[i - 1][j][k])
      Print(i - 1, j, k);
    else
      Print(i, j - 1, k);
  }
}
int main() {
  while (cin >> (a + 1) >> (b + 1) >> (c + 1)) {
    an = strlen(a + 1);
    bn = strlen(b + 1);
    cn = strlen(c + 1);
    memset(dp, -1, sizeof(dp));
    getFail(c, cn);
    int res = dfs(an, bn, cn);
    if (res == 0)
      printf("0");
    else
      Print(an, bn, cn);
    puts("");
  }
  return 0;
}