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 long long MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;
priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;
char s1[101], s2[101], vi[101];
int dp[100][100][100];
int tra[100][100][100];
int fail[101];
int n, m, b;
int go(int o, int oo, int ooo) {
  if (ooo == b) return -1e9;
  if (o == n || oo == m) return 0;
  if (dp[o][oo][ooo] != -1) return dp[o][oo][ooo];
  int mav = -1e9, t;
  t = go(o + 1, oo, ooo);
  if (mav < t) {
    mav = t;
    tra[o][oo][ooo] = 0;
  }
  t = go(o, oo + 1, ooo);
  if (mav < t) {
    mav = t;
    tra[o][oo][ooo] = 1;
  }
  if (s1[o] == s2[oo]) {
    int to = ooo;
    while (vi[to] != s1[o]) {
      if (!to) {
        to = -1;
        break;
      }
      to = fail[to];
    }
    to++;
    t = go(o + 1, oo + 1, to) + 1;
    if (mav < t) {
      mav = t;
      tra[o][oo][ooo] = 2;
    }
  }
  return dp[o][oo][ooo] = mav;
}
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%s %s %s", s1, s2, vi);
  n = strlen(s1);
  m = strlen(s2);
  b = strlen(vi);
  for (int i = 1; i < b; i++)
    for (int j = 0; j < b; j++) {
      if (vi[i + j] == vi[j])
        fail[i + j + 1] = max(fail[i + j + 1], j + 1);
      else
        break;
    }
  int t = go(0, 0, 0);
  if (!t) return !printf("%d", t);
  int o = 0, oo = 0, ooo = 0;
  while (o != n && oo != m) {
    if (tra[o][oo][ooo] == 0)
      o++;
    else if (tra[o][oo][ooo] == 1)
      oo++;
    else {
      printf("%c", s1[o]);
      int to = ooo;
      while (vi[to] != s1[o]) {
        if (!to) {
          to = -1;
          break;
        }
        to = fail[to];
      }
      to++;
      o++;
      oo++;
      ooo = to;
    }
  }
}