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 MAX_N = 100;
struct Trpl {
  int i, j, k;
  Trpl() {}
  Trpl(int _i, int _j, int _k) : i(_i), j(_j), k(_k) {}
};
char s[MAX_N + 4], t[MAX_N + 4], v[MAX_N + 4], w[MAX_N + 4];
int vt[MAX_N][26];
int dp[MAX_N + 1][MAX_N + 1][MAX_N];
Trpl ps[MAX_N + 1][MAX_N + 1][MAX_N];
int main() {
  scanf("%s%s%s", s, t, v);
  int sn = strlen(s), tn = strlen(t), vn = strlen(v);
  for (int i = 0; i < vn; i++) {
    for (int j = 0; j < 26; j++) {
      w[i] = 'A' + j;
      for (int k = 0, l = i + 1; k <= i; k++, l--)
        if (!strncmp(v, w + k, l)) {
          vt[i][j] = l;
          break;
        }
    }
    w[i] = v[i];
  }
  memset(dp, -1, sizeof(dp));
  dp[0][0][0] = 0;
  ps[0][0][0] = Trpl(-1, -1, -1);
  for (int i = 0; i <= sn; i++)
    for (int j = 0; j <= tn; j++)
      for (int k = 0; k < vn; k++) {
        if (i < sn && j < tn && s[i] == t[j]) {
          int d1 = dp[i][j][k] + 1;
          int k1 = vt[k][s[i] - 'A'];
          if (k1 < vn && dp[i + 1][j + 1][k1] < d1) {
            dp[i + 1][j + 1][k1] = d1;
            ps[i + 1][j + 1][k1] = Trpl(i, j, k);
          }
        }
        if (i < sn && dp[i + 1][j][k] < dp[i][j][k]) {
          dp[i + 1][j][k] = dp[i][j][k];
          ps[i + 1][j][k] = Trpl(i, j, k);
        }
        if (j < tn && dp[i][j + 1][k] < dp[i][j][k]) {
          dp[i][j + 1][k] = dp[i][j][k];
          ps[i][j + 1][k] = Trpl(i, j, k);
        }
      }
  int maxd = -1, maxk = -1;
  for (int k = 0; k < vn; k++)
    if (maxd < dp[sn][tn][k]) maxd = dp[sn][tn][k], maxk = k;
  if (maxd == 0)
    puts("0");
  else {
    int l = 0;
    for (int i = sn, j = tn, k = maxk; i >= 0;) {
      Trpl p = ps[i][j][k];
      if (p.i < 0) break;
      if (p.i < i && p.j < j) w[l++] = s[p.i];
      i = p.i, j = p.j, k = p.k;
    }
    for (int i = l - 1; i >= 0; i--) putchar(w[i]);
    putchar('\n');
  }
  return 0;
}