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;
struct node {
  int next[26], val, fail;
  void init() {
    memset(next, 0, sizeof(next));
    val = -1;
    fail = 0;
  }
};
node tree[10 * 110];
int all = 0;
int dp[110][110][3 * 110];
string an[110][110][2 * 110];
void init_an(int len1, int len2) {
  int i, j, k;
  for (i = 0; i <= len1; i++)
    for (j = 0; j <= len2; j++)
      for (k = 0; k <= all; k++) an[i][j][k] = "\0";
}
void insert(char *s, int v) {
  int i, p, t;
  p = 0;
  for (i = 0; s[i]; i++) {
    t = s[i] - 'A';
    if (tree[p].next[t] == 0) {
      tree[p].next[t] = ++all;
      tree[all].init();
    }
    p = tree[p].next[t];
  }
  tree[p].val = v;
}
int que[10 * 110];
void build_ac() {
  int head, tail, i, p, t;
  head = tail = 0;
  que[head++] = 0;
  while (head != tail) {
    t = que[tail++];
    for (i = 0; i < 26; i++) {
      p = tree[t].next[i];
      if (p == 0)
        tree[t].next[i] = tree[tree[t].fail].next[i];
      else
        que[head++] = p;
      if (p != 0 && t != 0) {
        tree[p].fail = tree[tree[t].fail].next[i];
      }
    }
  }
}
void update(int i, int j, int k, int x, int y, int z, int w) {
  if (dp[i][j][k] < dp[x][y][z] + w) {
    dp[i][j][k] = dp[x][y][z] + w;
    an[i][j][k] = an[x][y][z];
  }
}
char str1[110], str2[110], str[110];
int main() {
  while (cin >> str1 + 1 >> str2 + 1 >> str) {
    memset(dp, -1, sizeof(dp));
    all = 0;
    tree[0].init();
    insert(str, 1);
    build_ac();
    int i, j, k;
    int len1, len2;
    len1 = strlen(str1 + 1);
    len2 = strlen(str2 + 1);
    init_an(len1, len2);
    for (i = 0; i <= len1; i++)
      for (j = 0; j <= len2; j++) dp[i][j][0] = 0;
    for (i = 1; i <= len1; i++)
      for (j = 1; j <= len2; j++) {
        int p;
        for (k = 0; k <= all; k++) {
          p = tree[k].next[str1[i] - 'A'];
          update(i, j, k, i - 1, j, k, 0);
          update(i, j, k, i, j - 1, k, 0);
          update(i, j, k, i - 1, j - 1, k, 0);
          if (str1[i] == str2[j]) {
            if (tree[p].val == 1) continue;
            if (dp[i][j][p] < dp[i - 1][j - 1][k] + 1) {
              dp[i][j][p] = dp[i - 1][j - 1][k] + 1;
              an[i][j][p] = an[i - 1][j - 1][k] + str1[i];
            }
          }
        }
      }
    int ans = 0;
    k = 0;
    for (i = 0; i <= all; i++) {
      if (tree[i].val == 1) continue;
      if (ans < dp[len1][len2][i]) {
        ans = dp[len1][len2][i];
        k = i;
      }
    }
    if (ans == 0) {
      cout << ans << endl;
      continue;
    }
    cout << an[len1][len2][k] << endl;
  }
}