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>
int next[110];
char s[3][110];
int L[3];
int dp[110][110][110];
int pre[110][110][110];
int encode(int i, int j, int k) { return i * 1000000 + j * 1000 + k; }
void update(int i, int j, int k, int ii, int jj, int kk, int val) {
  if (dp[i][j][k] < val + dp[ii][jj][kk]) {
    pre[i][j][k] = encode(ii, jj, kk);
    dp[i][j][k] = val + dp[ii][jj][kk];
  }
}
void read_init() {
  for (int i = 0; i < 3; ++i) gets(s[i] + 1);
  for (int i = 0; i < 3; ++i) L[i] = strlen(s[i] + 1);
  next[1] = 1;
  int j = 1;
  for (int i = 2; i < L[2]; ++i) {
    if (s[2][i] == s[2][j])
      next[i] = ++j;
    else {
      j = next[i - 1];
      while (j > 1 && s[2][i] != s[2][j]) j = next[j - 1];
      if (j == 1 && s[2][i] != s[2][j])
        next[i] = 1;
      else
        next[i] = j + 1;
    }
  }
}
void output(int i, int j, int k) {
  if (dp[i][j][k] == 0) return;
  int pid = pre[i][j][k];
  int pi = pid / 1000000, pj = (pid / 1000) % 1000, pk = pid % 1000;
  output(pi, pj, pk);
  if (dp[i][j][k] == dp[pi][pj][pk] + 1) putchar(s[0][i]);
}
int main() {
  read_init();
  for (int i = 1; i <= L[0]; ++i)
    for (int j = 1; j <= L[1]; ++j) {
      update(i, j, 0, i - 1, j, 0, 0);
      update(i, j, 0, i, j - 1, 0, 0);
      update(i, j, 1, i - 1, j, 1, 0);
      update(i, j, 1, i, j - 1, 1, 0);
      if (s[0][i] == s[1][j]) {
        if (s[0][i] != s[2][1]) {
          update(i, j, 0, i - 1, j - 1, 0, 1);
        } else
          update(i, j, 1, i - 1, j - 1, 0, 1);
      }
      for (int k = 2; k <= L[2]; ++k) {
        update(i, j, k, i - 1, j, k, 0);
        update(i, j, k, i, j - 1, k, 0);
        if (s[0][i] != s[1][j]) continue;
        if (dp[i - 1][j - 1][k - 1] == 0) continue;
        int t = k;
        while (t >= 1 && s[0][i] != s[2][t]) t = next[t - 1];
        update(i, j, t, i - 1, j - 1, k - 1, 1);
      }
    }
  for (int i = 0; i <= L[0]; ++i)
    for (int j = 0; j <= L[1]; ++j)
      for (int k = 0; k <= L[2] - 1; ++k) update(105, 105, 105, i, j, k, 0);
  if (dp[105][105][105]) {
    output(105, 105, 105);
    puts("");
  } else
    puts("0");
  return 0;
}