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 a, b, v;
int mem[105][105][105];
int las[105][26];
string s;
int get(int ind, char ch) {
  if (las[ind][ch - 'A'] != -1) return las[ind][ch - 'A'];
  las[ind][ch - 'A'] = 0;
  for (int i = 1; i <= ind + 1; i++) {
    string z = v.substr(0, i);
    string m = v.substr(ind - i + 1, i - 1) + ch;
    if (z == m) las[ind][ch - 'A'] = i;
  }
  return las[ind][ch - 'A'];
}
int go(int x, int y, int z) {
  if (z == v.size()) return -(1 << 30);
  if (x == a.size() || y == b.size()) return 0;
  if (mem[x][y][z] != -1) return mem[x][y][z];
  mem[x][y][z] = 0;
  mem[x][y][z] = max(go(x + 1, y, z), go(x, y + 1, z));
  if (a[x] == b[y]) {
    if (v[z] == a[x])
      mem[x][y][z] = max(mem[x][y][z], 1 + go(x + 1, y + 1, z + 1));
    else
      mem[x][y][z] = max(mem[x][y][z], 1 + go(x + 1, y + 1, get(z, a[x])));
  }
  return mem[x][y][z];
}
void build(int x, int y, int z) {
  if (z == v.size() || x == a.size() || y == b.size()) return;
  if (mem[x][y][z] == 0) return;
  if (mem[x][y][z] == go(x + 1, y, z)) {
    build(x + 1, y, z);
    return;
  }
  if (mem[x][y][z] == go(x, y + 1, z)) {
    build(x, y + 1, z);
    return;
  }
  if (a[x] == b[y]) {
    if (v[z] == a[x] && mem[x][y][z] == 1 + go(x + 1, y + 1, z + 1)) {
      s += a[x];
      build(x + 1, y + 1, z + 1);
      return;
    } else if (v[z] != a[x] &&
               mem[x][y][z] == 1 + go(x + 1, y + 1, get(z, a[x]))) {
      s += a[x];
      build(x + 1, y + 1, get(z, a[x]));
      return;
    }
  }
}
int main() {
  cin >> a >> b >> v;
  memset(mem, -1, sizeof mem);
  memset(las, -1, sizeof las);
  go(0, 0, 0);
  build(0, 0, 0);
  if (s.size() == 0)
    cout << 0 << endl;
  else
    cout << s << endl;
}