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 = 105;
string virus, s1, s2;
int INF = 100000;
int b[MAX], n1, n2, m;
void kmpTable() {
  int i = 0, j = -1;
  b[0] = -1;
  while (i < m) {
    while (j >= 0 && virus[i] != virus[j]) j = b[j];
    i++, j++;
    b[i] = j;
  }
}
string memo[MAX][MAX][MAX];
bool flag[MAX][MAX][MAX];
string solve(int x, int y, int z) {
  string r, r1 = "", r2 = "", r3 = "";
  if (flag[x][y][z]) return memo[x][y][z];
  if (x >= n1 || y >= n2) {
    return "";
  }
  if (s1[x] == s2[y]) {
    if (s1[x] == virus[z]) {
      if (z + 1 < m) {
        r1 = s1[x] + solve(x + 1, y + 1, z + 1);
      }
    } else {
      int tmp = z;
      while (tmp >= 0 && s1[x] != virus[tmp]) tmp = b[tmp];
      if (tmp >= 0 && s1[x] == virus[tmp]) {
        if (tmp + 1 < m) {
          r1 = s1[x] + solve(x + 1, y + 1, tmp + 1);
        }
      } else {
        r1 = s1[x] + solve(x + 1, y + 1, 0);
      }
    }
  }
  r2 = solve(x + 1, y, z);
  r3 = solve(x, y + 1, z);
  int rmax = max(r1.size(), max(r2.size(), r3.size()));
  if (r1.size() == rmax) r = r1;
  if (r2.size() == rmax) r = r2;
  if (r3.size() == rmax) r = r3;
  r1 = solve(x + 1, y + 1, z);
  if (r1.size() > r.size()) r = r1;
  flag[x][y][z] = true;
  return memo[x][y][z] = r;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  for (int i = 0; i < MAX; i++)
    for (int j = 0; j < MAX; j++)
      for (int k = 0; k < MAX; k++) memo[i][j][k] = "";
  cin >> s1 >> s2 >> virus;
  n1 = s1.size();
  n2 = s2.size();
  m = virus.size();
  kmpTable();
  string ans = solve(0, 0, 0);
  if (ans != "")
    cout << ans << "\n";
  else
    cout << "0\n";
  return 0;
}