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 p[102][102][102], d[102][102][102], prf[102];
char s1[102], s2[102], s3[102];
bool mex(int &a, int b) {
  if (b > a) {
    a = b;
    return true;
  } else
    return false;
}
void init() {
  scanf("%s %s %s", s1, s2, s3);
  prf[0] = -1;
  prf[1] = 0;
  for (int i = 1; s3[i]; i++) {
    int cur = prf[i];
    while (cur >= 0 && s3[cur] != s3[i]) cur = prf[cur];
    cur++;
    prf[i + 1] = cur;
  }
}
int dp(int a, int b, int c) {
  if (s3[c] == 0) return -3;
  if (s1[a] == 0 || s2[b] == 0) return 0;
  int &ans = d[a][b][c];
  int &par = p[a][b][c];
  if (ans) return ans - 6;
  if (mex(ans, dp(a + 1, b, c))) {
    par = 3;
  }
  if (mex(ans, dp(a, b + 1, c))) {
    par = 2;
  }
  if (s1[a] == s2[b]) {
    int f = c;
    while (f >= 0 && s3[f] != s1[a]) {
      f = prf[f];
    }
    f++;
    if (mex(ans, dp(a + 1, b + 1, f) + 1)) {
      par = 1;
    }
  }
  ans += 6;
  return ans - 6;
}
void rec(int a, int b, int c) {
  while (true) {
    switch (p[a][b][c]) {
      case 1: {
        printf("%c", s1[a]);
        while (c >= 0 && s1[a] != s3[c]) c = prf[c];
        a++;
        b++;
        c++;
      } break;
      case 2: {
        b++;
      } break;
      case 3: {
        a++;
      } break;
      default:
        return;
        break;
    }
  }
}
void solve() {
  int ans = dp(0, 0, 0);
  if (ans)
    rec(0, 0, 0);
  else
    printf("0");
}
int main() {
  init();
  solve();
  return 0;
}