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;
inline int Min(int a, int b) { return (a < b ? a : b); }
inline int Max(int a, int b) { return (a > b ? a : b); }
char S1[105];
char S2[105];
char C[105];
int DP[105][105][105];
bool vis[105][105][105];
int sigPos[105][105 * 3];
int M;
bool checa(int pos, int i, int x) {
  if (C[pos] != x) return false;
  for (int j = pos - 1; j >= 0; j--) {
    i--;
    if (C[j] != C[i]) return false;
  }
  return true;
}
int busca(int pos, int pos2, int pos3) {
  if (!C[pos3]) return -987654321;
  if (S1[pos] == 0 || S2[pos2] == 0) return 0;
  if (vis[pos][pos2][pos3]) return DP[pos][pos2][pos3];
  vis[pos][pos2][pos3] = true;
  if (S1[pos] == S2[pos2])
    DP[pos][pos2][pos3] = busca(pos + 1, pos2 + 1, sigPos[pos3][S1[pos]]) + 1;
  return DP[pos][pos2][pos3] =
             Max(DP[pos][pos2][pos3],
                 Max(busca(pos + 1, pos2, pos3), busca(pos, pos2 + 1, pos3)));
}
void recon(int pos, int pos2, int pos3) {
  if (!C[pos3]) return;
  if (S1[pos] == 0 || S2[pos2] == 0) return;
  if (S1[pos] == S2[pos2] &&
      DP[pos][pos2][pos3] ==
          busca(pos + 1, pos2 + 1, sigPos[pos3][S1[pos]]) + 1) {
    printf("%c", S1[pos]);
    recon(pos + 1, pos2 + 1, sigPos[pos3][S1[pos]]);
  } else if (DP[pos][pos2][pos3] == busca(pos + 1, pos2, pos3)) {
    recon(pos + 1, pos2, pos3);
  } else {
    recon(pos, pos2 + 1, pos3);
  }
}
int main() {
  scanf("%s %s %s", S1, S2, C);
  for (M = 0; C[M]; M++)
    ;
  for (int i = 0; C[i]; i++) {
    for (int j = 'A'; j <= 'Z'; j++) {
      int k = i;
      for (; k >= 0; k--) {
        if (checa(k, i, j)) {
          sigPos[i][j] = k + 1;
          break;
        }
      }
    }
  }
  if (busca(0, 0, 0) == 0)
    printf("0\n");
  else
    recon(0, 0, 0);
  return 0;
}