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>
const int mx = 110;
char s[mx], t[mx], v[mx];
int next[mx];
int f[mx][mx][mx], from[mx][mx][mx];
void getnext(int l) {
  int i = 1, j = 0;
  next[1] = 0;
  while (i < l) {
    if (j == 0 || v[i] == v[j]) {
      i++;
      j++;
      next[i] = j;
    } else
      j = next[j];
  }
}
void dfs(int n, int m, int ans) {
  if (from[n][m][ans] == -1)
    return;
  else if (from[n][m][ans] == -2)
    dfs(n - 1, m, ans);
  else if (from[n][m][ans] == -3)
    dfs(n, m - 1, ans);
  else {
    dfs(n - 1, m - 1, from[n][m][ans]);
    putchar(s[n]);
  }
}
int main() {
  scanf("%s%s%s", s + 1, t + 1, v + 1);
  int n = strlen(s + 1), m = strlen(t + 1), l = strlen(v + 1);
  getnext(l);
  memset(from, -1, sizeof(from));
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      for (int k = 0; k < l; k++) {
        if (f[i][j][k] > f[i + 1][j][k]) {
          f[i + 1][j][k] = f[i][j][k];
          from[i + 1][j][k] = -2;
        }
        if (f[i][j][k] > f[i][j + 1][k]) {
          f[i][j + 1][k] = f[i][j][k];
          from[i][j + 1][k] = -3;
        }
        if (s[i + 1] == t[j + 1]) {
          int got;
          if (s[i + 1] == v[k + 1])
            got = k + 1;
          else {
            got = next[k + 1];
            while (got) {
              if (s[i + 1] == v[got]) break;
              got = next[got];
            }
          }
          if (f[i][j][k] + 1 > f[i + 1][j + 1][got]) {
            f[i + 1][j + 1][got] = f[i][j][k] + 1;
            from[i + 1][j + 1][got] = k;
          }
        }
      }
  int ans = 0;
  for (int i = 1; i < l; i++)
    if (f[n][m][i] > f[n][m][ans]) ans = i;
  dfs(n, m, ans);
  if (!f[n][m][ans])
    puts("0");
  else
    puts("");
  return 0;
}