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 s1, s2, virus;
int pArray[110], nxt[110][30];
void process(string s) {
  pArray[0] = -1;
  int i = 0, j = -1;
  while (i < s.size()) {
    while (j >= 0 && s[i] != s[j]) j = pArray[j];
    i++;
    j++;
    pArray[i] = j;
  }
}
bool calc[110][110][110];
string dp[110][110][110];
string solve(int x, int y, int v) {
  if (x == s1.size() || y == s2.size()) return "";
  if (calc[x][y][v]) return dp[x][y][v];
  string ret = "";
  if (s1[x] == s2[y]) {
    string add1 = "", add2 = "";
    add1 += s1[x];
    add2 += s1[x];
    if (s1[x] != virus[v]) {
      add1 += solve(x + 1, y + 1, nxt[v][s1[x] - 'A']);
      ret = add1;
    } else if (v + 1 < virus.size()) {
      add2 += solve(x + 1, y + 1, v + 1);
      ret = add2;
    }
  }
  string a = solve(x + 1, y, v), b = solve(x, y + 1, v);
  if (a.size() > ret.size()) ret = a;
  if (b.size() > ret.size()) ret = b;
  calc[x][y][v] = true;
  return dp[x][y][v] = ret;
}
int main() {
  cin >> s1 >> s2 >> virus;
  for (int i = 0; i < 110; i++)
    for (int j = 0; j < 110; j++)
      for (int k = 0; k < 110; k++) {
        dp[i][j][k] = "";
        calc[i][j][k] = false;
      }
  process(virus);
  for (int i = 1; i < 110; i++)
    for (int j = 0; j < 26; j++) {
      int newv = i;
      while (newv >= 0 && (j + 'A') != virus[newv]) newv = pArray[newv];
      newv++;
      nxt[i][j] = newv;
    }
  string ans = solve(0, 0, 0);
  if (ans.size() == 0)
    printf("0\n");
  else
    cout << ans << endl;
  return 0;
}