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;
int n, m, z, dp[101][101][101], b[1001];
pair<int, int> p[101][101][101];
string s1, s2, vir, P;
int rec(int p1, int p2, int v) {
  if (v >= z) return -10000000;
  if (p1 == n || p2 == m) return 0;
  if (~dp[p1][p2][v]) return dp[p1][p2][v];
  int pt, ret = 0, be, v2 = v;
  be = 1;
  pt = v;
  ret = rec(p1 + 1, p2, v);
  int tmp = rec(p1, p2 + 1, v);
  if (ret < tmp) {
    ret = tmp;
    be = 2;
  }
  if (s1[p1] == s2[p2]) {
    while (v2 >= 0 && s1[p1] != P[v2]) v2 = b[v2];
    tmp = rec(p1 + 1, p2 + 1, v2 + 1) + 1;
    if (ret < tmp) {
      pt = v2 + 1;
      ret = tmp;
      be = 4;
    }
  }
  p[p1][p2][v] = make_pair(be, pt);
  return dp[p1][p2][v] = ret;
}
void kmpPreprocess() {
  int i = 0, j = -1;
  b[0] = -1, m = P.size();
  while (i < m) {
    while (j >= 0 && P[i] != P[j]) j = b[j];
    i++;
    j++;
    b[i] = j;
  }
}
int main() {
  cin >> s1 >> s2 >> vir;
  P = vir;
  kmpPreprocess();
  memset((dp), (-1), sizeof(dp));
  n = s1.size(), m = s2.size(), z = vir.size();
  int f = rec(0, 0, 0);
  if (f <= 0)
    cout << 0;
  else {
    int a = 0, b = 0, v = 0;
    while (a < n && b < m) {
      if (p[a][b][v].first == 4) {
        cout << s1[a];
        v = p[a][b][v].second;
        a++, b++;
      } else if (p[a][b][v].first == 1) {
        a++;
      } else if (p[a][b][v].first == 2)
        b++;
      else
        a++, b++;
    }
  }
  return 0;
}