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;
const int N = 110;
int n, m, t, tot = 1;
int nex[N][30], fail[N];
char s1[N], s2[N], s3[N];
void insert() {
  int p = 1;
  for (int i = 1; i <= t; i++) {
    int id = s3[i] - 'A';
    if (nex[p][id] == 0) nex[p][id] = ++tot;
    p = nex[p][id];
  }
}
void get() {
  for (int i = 0; i < 26; i++) nex[0][i] = 1;
  queue<int> Q;
  Q.push(1);
  while (!Q.empty()) {
    int pre = Q.front();
    Q.pop();
    for (int i = 0; i < 26; i++) {
      if (nex[pre][i] == 0) continue;
      int p = fail[pre];
      while (nex[p][i] == 0) p = fail[p];
      p = nex[p][i];
      fail[nex[pre][i]] = p;
      Q.push(nex[pre][i]);
    }
  }
}
struct node {
  int a, b, c;
  node() {}
  node(int a, int b, int c) : a(a), b(b), c(c) {}
};
int dp[N][N][N];
node fr[N][N][N];
void solve(int i, int j, int k) {
  if (i == 0 || j == 0) return;
  int ii = fr[i][j][k].a;
  int jj = fr[i][j][k].b;
  int kk = fr[i][j][k].c;
  solve(ii, jj, kk);
  if (dp[i][j][k] != dp[ii][jj][kk]) printf("%c", s1[i]);
}
int main() {
  scanf("%s%s%s", s1 + 1, s2 + 1, s3 + 1);
  n = strlen(s1 + 1);
  m = strlen(s2 + 1);
  t = strlen(s3 + 1);
  insert();
  get();
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      for (int k = 0; k < N; k++) dp[i][j][k] = -1e9;
  dp[0][0][1] = 0;
  for (int i = 0; i < N; i++) dp[i][0][1] = dp[0][i][1] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = 1; k < tot; k++) {
        if (dp[i - 1][j - 1][k] > dp[i][j][k])
          dp[i][j][k] = dp[i - 1][j - 1][k],
          fr[i][j][k] = node(i - 1, j - 1, k);
        if (dp[i - 1][j][k] > dp[i][j][k])
          dp[i][j][k] = dp[i - 1][j][k], fr[i][j][k] = node(i - 1, j, k);
        if (dp[i][j - 1][k] > dp[i][j][k])
          dp[i][j][k] = dp[i][j - 1][k], fr[i][j][k] = node(i, j - 1, k);
        if (s1[i] == s2[j]) {
          int p = k;
          while (nex[p][s1[i] - 'A'] == 0) {
            p = fail[p];
          }
          p = nex[p][s1[i] - 'A'];
          if (dp[i - 1][j - 1][k] + 1 > dp[i][j][p])
            dp[i][j][p] = dp[i - 1][j - 1][k] + 1,
            fr[i][j][p] = node(i - 1, j - 1, k);
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i < tot; i++) {
    ans = max(ans, dp[n][m][i]);
  }
  if (ans == 0) {
    puts("0");
  } else {
    for (int i = 1; i < tot; i++) {
      if (dp[n][m][i] == ans) {
        solve(n, m, i);
        puts("");
        break;
      }
    }
  }
  return 0;
}