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 long long INF = 1e18;
const long long mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e2 + 10;
long long qpow(long long x, long long y, long long MOD) {
  long long a = 1;
  while (y) {
    if (y & 1) a = a * x % MOD;
    x = x * x % MOD;
    y >>= 1;
  }
  return a;
}
struct node {
  int x, y, l;
  char ch;
} path[N][N][N];
int dp[N][N][N];
char s[N], t[N], vs[N];
int nxt[N];
void get_nxt(char s[], int m) {
  nxt[0] = -1;
  int i = 0, j = -1;
  while (i < m) {
    while (j != -1 && s[i] != s[j]) j = nxt[j];
    nxt[++i] = ++j;
  }
}
int main() {
  scanf("%s%s%s", s + 1, t + 1, vs);
  int n = strlen(s + 1), m = strlen(t + 1), len = strlen(vs);
  get_nxt(vs, len);
  memset(dp, -1, sizeof(dp));
  dp[0][0][0] = 0;
  for (int i = int(0); i <= int(n); ++i)
    for (int j = int(0); j <= int(m); ++j) {
      for (int k = int(0); k <= int(len - 1); ++k) {
        if (i && dp[i - 1][j][k] > dp[i][j][k]) {
          dp[i][j][k] = dp[i - 1][j][k];
          path[i][j][k] = path[i - 1][j][k];
        }
        if (j && dp[i][j - 1][k] > dp[i][j][k]) {
          dp[i][j][k] = dp[i][j - 1][k];
          path[i][j][k] = path[i][j - 1][k];
        }
      }
      if (s[i] == t[j] && i && j) {
        for (int k = int(0); k <= int(len - 1); ++k) {
          if (dp[i - 1][j - 1][k] != -1) {
            int nk = k;
            while (nk != -1 && vs[nk] != s[i]) nk = nxt[nk];
            if (dp[i - 1][j - 1][k] + 1 > dp[i][j][nk + 1]) {
              dp[i][j][nk + 1] = dp[i - 1][j - 1][k] + 1;
              path[i][j][nk + 1] = {i - 1, j - 1, k, s[i]};
            }
          }
        }
      }
    }
  int ans = -inf;
  for (int i = int(0); i <= int(len - 1); ++i) ans = max(ans, dp[n][m][i]);
  if (ans <= 0) {
    puts("0");
    return 0;
  }
  vector<char> vec;
  for (int i = int(0); i <= int(len - 1); ++i) {
    if (dp[n][m][i] == ans) {
      int x = n, y = m, c = i;
      while (1) {
        vec.push_back(path[x][y][c].ch);
        if ((int)vec.size() == ans) break;
        int xx = path[x][y][c].x, yy = path[x][y][c].y, cc = path[x][y][c].l;
        x = xx, y = yy, c = cc;
      }
      break;
    }
  }
  for (int i = vec.size() - 1; i >= 0; --i) {
    printf("%c", vec[i]);
  }
  return 0;
}