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, v;
vector<int> pre;
vector<int> kmp(string s) {
  int len = s.size();
  vector<int> p(len);
  int x = 0;
  for (int i = 1; i < len; i++) {
    x = p[i - 1];
    while (x && s[i] != s[x]) x = p[x - 1];
    if (s[i] == s[x]) x++;
    p[i] = x;
  }
  return p;
}
int dp[110][110][110];
pair<int, int> dir[110][110][110];
int f(int i, int j, int k) {
  if (k >= v.size()) return -10000;
  if (i == s1.size() || j == s2.size()) return 0;
  if (dp[i][j][k] != -1) return dp[i][j][k];
  int r1 = f(i + 1, j, k);
  int r2 = f(i, j + 1, k);
  int dr = 0;
  int lv = k;
  if (r1 > r2) {
    dr = 1;
  } else
    dr = 2;
  r1 = max(r1, r2);
  int x = k;
  if (s1[i] == s2[j]) {
    if (x) x == pre[k - 1];
    while (x && s1[i] != v[x]) x = pre[x - 1];
    if (s1[i] == v[x]) x++;
    r2 = f(i + 1, j + 1, x) + 1;
    if (r2 > r1) {
      dr = 3;
      r1 = r2;
      lv = x;
    }
  }
  dir[i][j][k] = make_pair(dr, lv);
  return dp[i][j][k] = r1;
}
int main() {
  while (cin >> s1 >> s2 >> v) {
    pre = kmp(v);
    memset(dp, -1, sizeof(dp));
    int len = f(0, 0, 0);
    int x = 0, y = 0, z = 0;
    if (!len)
      cout << "0";
    else
      while (len) {
        if (dir[x][y][z].first == 1) {
          z = dir[x][y][z].second;
          x++;
        } else if (dir[x][y][z].first == 2) {
          z = dir[x][y][z].second;
          y++;
        } else {
          cout << s1[x];
          z = dir[x][y][z].second;
          len--;
          x++;
          y++;
        }
      }
    cout << endl;
  }
  return 0;
}