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 aux[102][30], dp[102][102][102], path[102][102][102][4];
char s1[102], s2[102], s3[102], t[102];
int l1, l2, l3;
int calc(int z) {
  for (int i = 0; i < z; i++) {
    int x = 0, g = 1;
    for (int j = 0; j < l3 && g; j++) {
      if (i + j == z) break;
      if (t[i + j] != s3[j]) g = 0;
      x++;
    }
    if (g) return x;
  }
  return 0;
}
void pre() {
  for (int i = 0; i < l3; i++) {
    for (int j = 0; j < 26; j++) {
      t[i] = 'A' + j;
      aux[i][j] = calc(i + 1);
    }
    t[i] = s3[i];
  }
}
int solve(int p1, int p2, int p3) {
  if (p3 == l3) return -10000000;
  if (p1 == l1) return 0;
  if (p2 == l2) return 0;
  if (dp[p1][p2][p3] != -1) return dp[p1][p2][p3];
  int &res = dp[p1][p2][p3];
  res = 0;
  int q;
  q = solve(p1 + 1, p2, p3);
  if (q >= res)
    res = q, path[p1][p2][p3][0] = p1 + 1, path[p1][p2][p3][1] = p2,
    path[p1][p2][p3][2] = p3;
  q = solve(p1, p2 + 1, p3);
  if (q >= res)
    res = q, path[p1][p2][p3][0] = p1, path[p1][p2][p3][1] = p2 + 1,
    path[p1][p2][p3][2] = p3;
  if (s1[p1] == s2[p2]) {
    if (s1[p1] == s3[p3]) {
      q = 1 + solve(p1 + 1, p2 + 1, p3 + 1);
      if (q >= res)
        res = q, path[p1][p2][p3][0] = p1 + 1, path[p1][p2][p3][1] = p2 + 1,
        path[p1][p2][p3][2] = p3 + 1, path[p1][p2][p3][3] = p1;
    } else {
      q = 1 + solve(p1 + 1, p2 + 1, aux[p3][s1[p1] - 'A']);
      if (q >= res)
        res = q, path[p1][p2][p3][0] = p1 + 1, path[p1][p2][p3][1] = p2 + 1,
        path[p1][p2][p3][2] = aux[p3][s1[p1] - 'A'], path[p1][p2][p3][3] = p1;
    }
  }
  return res;
}
void Print_function(int p1, int p2, int p3) {
  if (p1 == l1 || p2 == l2 || p3 == l3) return;
  int n1, n2, n3;
  n1 = path[p1][p2][p3][0];
  n2 = path[p1][p2][p3][1];
  n3 = path[p1][p2][p3][2];
  if (path[p1][p2][p3][3] != -1) printf("%c", s1[p1]);
  Print_function(n1, n2, n3);
}
int main(void) {
  while (scanf("%s%s%s", s1, s2, s3) != EOF) {
    l1 = strlen(s1);
    l2 = strlen(s2);
    l3 = strlen(s3);
    pre();
    memset(dp, -1, sizeof(dp));
    memset(path, -1, sizeof(path));
    int ans = solve(0, 0, 0);
    if (ans == 0) {
      cout << "0\n";
      continue;
    }
    Print_function(0, 0, 0);
    puts("");
  }
}