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>
char sa[110];
char sb[110];
char sc[110];
int sal, sbl, scl;
int dp[110][110][110];
int bdp[110][110][110][4];
int ff[110];
char out[110];
int main() {
  int i, j, k, l, t, ti, tj, tk;
  scanf("%s%s%s", sa, sb, sc);
  for (sal = 0; sa[sal]; sal++)
    ;
  for (sbl = 0; sb[sbl]; sbl++)
    ;
  for (scl = 0; sc[scl]; scl++)
    ;
  for (i = 0; i < scl; i++) {
    for (j = i - 1; j >= 0; j--) {
      for (k = 0; k < j; k++) {
        if (sc[k] != sc[i - j + k]) break;
      }
      if (k == j) {
        ff[i] = j;
        break;
      }
    }
  }
  for (i = 0; i <= sal; i++) {
    for (j = 0; j <= sbl; j++) {
      for (k = 1; k <= scl; k++) {
        dp[i][j][k] = -9999999;
      }
      for (k = 0; k <= scl; k++) {
        bdp[i][j][k][0] = -9999999;
      }
    }
  }
  for (i = 0; i <= sal; i++) {
    for (j = 0; j <= sbl; j++) {
      for (k = 0; k < scl; k++) {
        if (dp[i + 1][j][k] < dp[i][j][k]) {
          dp[i + 1][j][k] = dp[i][j][k];
          bdp[i + 1][j][k][0] = bdp[i][j][k][0];
          bdp[i + 1][j][k][1] = bdp[i][j][k][1];
          bdp[i + 1][j][k][2] = bdp[i][j][k][2];
        }
        if (dp[i][j + 1][k] < dp[i][j][k]) {
          dp[i][j + 1][k] = dp[i][j][k];
          bdp[i][j + 1][k][0] = bdp[i][j][k][0];
          bdp[i][j + 1][k][1] = bdp[i][j][k][1];
          bdp[i][j + 1][k][2] = bdp[i][j][k][2];
        }
      }
      if (i != sal && j != sbl && sa[i] == sb[j]) {
        for (k = 0; k < scl; k++) {
          t = 0;
          for (l = k; l != 0; l = ff[l]) {
            if (sc[l] == sa[i]) {
              t = l;
              break;
            }
          }
          if (sc[t] == sa[i]) t++;
          if (dp[i + 1][j + 1][t] < dp[i][j][k] + 1) {
            dp[i + 1][j + 1][t] = dp[i][j][k] + 1;
            bdp[i + 1][j + 1][t][0] = i;
            bdp[i + 1][j + 1][t][1] = j;
            bdp[i + 1][j + 1][t][2] = k;
          }
        }
      }
    }
  }
  t = 0;
  for (i = 1; i < scl; i++) {
    if (dp[sal][sbl][i] > dp[sal][sbl][t]) t = i;
  }
  if (dp[sal][sbl][t] == 0)
    printf("0");
  else {
    i = sal;
    j = sbl;
    k = t;
    ti = bdp[i][j][k][0];
    tj = bdp[i][j][k][1];
    tk = bdp[i][j][k][2];
    i = ti;
    j = tj;
    k = tk;
    while (dp[i][j][k] >= 0) {
      out[dp[i][j][k]] = sa[i];
      if (dp[i][j][k] == 0) break;
      ti = bdp[i][j][k][0];
      tj = bdp[i][j][k][1];
      tk = bdp[i][j][k][2];
      i = ti;
      j = tj;
      k = tk;
    }
    printf("%s", out);
  }
}