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;
#pragma comment(linker, "/STACK:64000000")
inline pair<pair<int, int>, int> make(int x, int y, int z) {
  return pair<pair<int, int>, int>(pair<int, int>(x, y), z);
}
const int MAXN = 102;
string s1, s2, virus;
int n, m, l;
int f[MAXN][MAXN][MAXN];
pair<pair<int, int>, int> p[MAXN][MAXN][MAXN];
int gp[MAXN][256];
inline int get_pref(int x, char c) {
  if (gp[x][(int)c] != -1) return gp[x][(int)c];
  int res = 0;
  string sa, sb;
  for (int i = x; i >= 0; --i) {
    sa = virus.substr(0, i + 1);
    sb = virus.substr(x - i, i) + c;
    if (sa == sb) {
      res = i + 1;
      break;
    }
  }
  return gp[x][(int)c] = res;
}
int rec(int x, int y, int z) {
  if (z == l) return -2;
  if (x == n || y == m) return 0;
  if (f[x][y][z] != -1) return f[x][y][z];
  int res = rec(x + 1, y, z);
  p[x][y][z] = make(x + 1, y, z);
  int cur = rec(x, y + 1, z);
  if (res < cur) {
    res = cur;
    p[x][y][z] = make(x, y + 1, z);
  }
  if (s1[x] == s2[y]) {
    int nz = get_pref(z, s1[x]);
    int cur = rec(x + 1, y + 1, nz);
    if (cur != -2) ++cur;
    if (res < cur) {
      res = cur;
      p[x][y][z] = make(x + 1, y + 1, nz);
    }
  }
  return f[x][y][z] = res;
}
inline void init() {
  memset(f, -1, sizeof f);
  memset(gp, -1, sizeof gp);
  cin >> s1 >> s2 >> virus;
  n = (int)s1.length();
  m = (int)s2.length();
  l = (int)virus.length();
}
int main() {
  init();
  int res = rec(0, 0, 0);
  if (!res || res == -2) {
    cout << 0 << endl;
    return 0;
  }
  string ans = "";
  int x = 0, y = 0, z = 0;
  while (x < n && y < m) {
    int nx = p[x][y][z].first.first;
    int ny = p[x][y][z].first.second;
    int nz = p[x][y][z].second;
    if (nx != x && ny != y) ans += s1[x];
    x = nx;
    y = ny;
    z = nz;
  }
  cout << ans << endl;
  return 0;
}