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 nxt[105];
void get_next(char *S, int *next) {
  int j = -1, m = strlen(S);
  next[0] = -1;
  for (int i = 1; i < m; i++) {
    while (~j && S[j + 1] != S[i]) j = next[j];
    if (S[j + 1] == S[i]) j++;
    next[i] = j;
  }
}
char S[2][105];
char vi[105];
string dp[105][105][105];
void calc(string &a, string b) {
  if (a.size() < b.size()) a = b;
}
int main() {
  scanf("%s%s%s", &S[0], &S[1], vi);
  get_next(vi, nxt);
  int n = strlen(S[0]), m = strlen(S[1]), l = strlen(vi);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < l; k++) {
        calc(dp[i + 1][j + 1][k + 1], dp[i][j + 1][k + 1]);
        calc(dp[i + 1][j + 1][k + 1], dp[i + 1][j][k + 1]);
        if (S[0][i] == S[1][j]) {
          int x = k - 1;
          while (~x && S[0][i] != vi[x + 1]) x = nxt[x];
          if (S[0][i] == vi[x + 1]) x++;
          if (x + 1 < l)
            calc(dp[i + 1][j + 1][x + 2], dp[i][j][k + 1] + S[0][i]);
        }
      }
    }
  }
  string ans = "";
  for (int i = 1; i <= l; i++) calc(ans, dp[n][m][i]);
  if (ans.size() == 0)
    puts("0");
  else
    cout << ans << endl;
  return 0;
}