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 read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!(ch >= '0' && ch <= '9')) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * f;
}
const int N = 105;
char s1[N], s2[N], virus[N];
int l1, l2, l3;
int nxt[N];
int dp[N][N][N], fr[N][N][N][2];
inline void refresh(int val, int tp, int pos, int &x, int &y, int &z) {
  if (val > x) x = val, y = tp, z = pos;
}
inline void print(int a, int b, int p) {
  if (a == 0 && b == 0) return;
  int tmp = fr[a][b][p][0];
  if (tmp == 1)
    print(a - 1, b, p);
  else if (tmp == 2)
    print(a, b - 1, p);
  else if (tmp == 3)
    print(a - 1, b - 1, fr[a][b][p][1]);
  if (tmp == 3) putchar(s1[a]);
}
int main() {
  scanf("%s", s1 + 1);
  l1 = strlen(s1 + 1);
  scanf("%s", s2 + 1);
  l2 = strlen(s2 + 1);
  scanf("%s", virus + 1);
  l3 = strlen(virus + 1);
  nxt[1] = 0;
  int p = 0, i = 2;
  while (i <= l3) {
    while (virus[p + 1] != virus[i] && p > 0) p = nxt[p];
    if (virus[p + 1] == virus[i]) p++;
    nxt[i] = p;
    i++;
  }
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i <= l1; i++) {
    for (int j = 0; j <= l2; j++) {
      for (int k = 0; k <= l3; k++) {
        refresh(dp[i][j][k], 1, k, dp[i + 1][j][k], fr[i + 1][j][k][0],
                fr[i + 1][j][k][1]);
        refresh(dp[i][j][k], 2, k, dp[i][j + 1][k], fr[i][j + 1][k][0],
                fr[i][j + 1][k][1]);
        if (s1[i + 1] != s2[j + 1]) continue;
        int nxtp;
        if (k < l3 && s1[i + 1] == virus[k + 1])
          nxtp = k + 1;
        else if (k == l3)
          nxtp = l3;
        else {
          nxtp = nxt[k];
          while (nxtp && virus[nxtp + 1] != s1[i + 1]) nxtp = nxt[nxtp];
          if (virus[nxtp + 1] == s1[i + 1]) nxtp++;
        }
        refresh(dp[i][j][k] + 1, 3, k, dp[i + 1][j + 1][nxtp],
                fr[i + 1][j + 1][nxtp][0], fr[i + 1][j + 1][nxtp][1]);
      }
    }
  }
  int mx = 0;
  for (int i = 0; i <= l3 - 1; i++)
    if (dp[l1][l2][i] > mx) mx = dp[l1][l2][i];
  if (mx) {
    for (int i = 0; i <= l3 - 1; i++)
      if (dp[l1][l2][i] == mx) {
        print(l1, l2, i);
        puts("");
        break;
      }
  } else
    puts("0");
  return 0;
}