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;
string s, t, p;
int d[105][105][105], nx[105];
struct ppp {
  int x, y, v;
} f[105][105][105];
void getnextval() {
  nx[0] = -1;
  long long i = 0, j = -1, len = t.length();
  while (i < len) {
    if (j == -1 || p[i] == p[j]) {
      i++;
      j++;
      nx[i] = j;
    } else
      j = nx[j];
  }
}
void print(int x, int y, int v) {
  if (x == 0 && y == 0 && v == 0) return;
  ppp c = f[x][y][v];
  print(c.x, c.y, c.v);
  if (d[x][y][v] == d[c.x][c.y][c.v] + 1) cout << s[x];
}
int main() {
  cin >> s >> t >> p;
  int n = s.length(), m = t.length(), l = p.length();
  s = " " + s;
  t = " " + t;
  getnextval();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = 0; k < l; k++) {
        if (d[i][j][k] < d[i - 1][j][k]) {
          d[i][j][k] = d[i - 1][j][k];
          f[i][j][k] = {i - 1, j, k};
        }
        if (d[i][j][k] < d[i][j - 1][k]) {
          d[i][j][k] = d[i][j - 1][k];
          f[i][j][k] = {i, j - 1, k};
        }
        if (s[i] == t[j]) {
          int pos = k;
          while (pos > 0 && s[i] != p[pos]) pos = nx[pos];
          if (p[pos] == s[i])
            pos++;
          else
            pos = 0;
          if (d[i][j][pos] < d[i - 1][j - 1][k] + 1) {
            d[i][j][pos] = d[i - 1][j - 1][k] + 1;
            f[i][j][pos] = {i - 1, j - 1, k};
          }
        }
      }
    }
  }
  int ans = 0, x = -1;
  for (int i = 0; i < l; i++) {
    if (ans < d[n][m][i]) ans = d[n][m][i], x = i;
  }
  if (!ans)
    cout << 0 << endl;
  else
    print(n, m, x);
}