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 dp[105][105][105], pre[105][105][105][3];
char s1[105], s2[105], vr[105];
int to[105][30];
void init() {
  int i, j, len = strlen(vr + 1);
  string s = vr + 1;
  for (i = 0; i <= len; i++)
    for (j = 0; j < 26; j++) {
      char ch = 'A' + j;
      if (ch == vr[i + 1])
        to[i][j] = i + 1;
      else {
        for (int k = i - 1; k >= 0; k--) {
          string tmp = s.substr(i - k, k) + ch;
          if (tmp == s.substr(0, k + 1)) {
            to[i][j] = k + 1;
            break;
          }
        }
      }
    }
}
int main() {
  scanf("%s%s%s", s1 + 1, s2 + 1, vr + 1);
  init();
  int i, j, k, len = strlen(vr + 1);
  int l1 = strlen(s1 + 1), l2 = strlen(s2 + 1);
  for (i = 0; i <= l1; i++)
    for (j = 0; j <= l2; j++)
      for (k = 0; k < len; k++) {
        if (dp[i][j + 1][k] < dp[i][j][k]) {
          dp[i][j + 1][k] = dp[i][j][k];
          pre[i][j + 1][k][0] = i;
          pre[i][j + 1][k][1] = j;
          pre[i][j + 1][k][2] = k;
        }
        if (dp[i + 1][j][k] < dp[i][j][k]) {
          dp[i + 1][j][k] = dp[i][j][k];
          pre[i + 1][j][k][0] = i;
          pre[i + 1][j][k][1] = j;
          pre[i + 1][j][k][2] = k;
        }
        if (i + 1 <= l1 && j + 1 <= l2 && (k == 0 || (k > 0 && dp[i][j][k]))) {
          if (s1[i + 1] == s2[j + 1]) {
            if (s1[i + 1] == vr[k + 1]) {
              if (dp[i + 1][j + 1][k + 1] < dp[i][j][k] + 1) {
                dp[i + 1][j + 1][k + 1] = dp[i][j][k] + 1;
                pre[i + 1][j + 1][k + 1][0] = i;
                pre[i + 1][j + 1][k + 1][1] = j;
                pre[i + 1][j + 1][k + 1][2] = k;
              }
            } else if (dp[i + 1][j + 1][to[k][s1[i + 1] - 'A']] <
                       dp[i][j][k] + 1) {
              dp[i + 1][j + 1][to[k][s1[i + 1] - 'A']] = dp[i][j][k] + 1;
              pre[i + 1][j + 1][to[k][s1[i + 1] - 'A']][0] = i;
              pre[i + 1][j + 1][to[k][s1[i + 1] - 'A']][1] = j;
              pre[i + 1][j + 1][to[k][s1[i + 1] - 'A']][2] = k;
            }
          }
        }
      }
  int M = 0, ii, jj, kk;
  for (i = 0; i <= l1; i++)
    for (j = 0; j <= l2; j++)
      for (k = 0; k < len; k++)
        if (dp[i][j][k] > M) M = dp[i][j][k], ii = i, jj = j, kk = k;
  if (M == 0) {
    puts("0");
    return 0;
  }
  char sta[105];
  int top = 0;
  while (ii >= 1 && jj >= 1) {
    int pi = pre[ii][jj][kk][0];
    int pj = pre[ii][jj][kk][1];
    int pk = pre[ii][jj][kk][2];
    if (dp[ii][jj][kk] == dp[pi][pj][pk] + 1) sta[top++] = s1[ii];
    ii = pi, jj = pj, kk = pk;
  }
  for (i = top - 1; i >= 0; i--) printf("%c", sta[i]);
  puts("");
}