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 inf = 0x3f3f3f3f;
const int maxn = 205;
int dp[maxn][maxn][maxn], ch[maxn][maxn];
bool vis[maxn][maxn][maxn];
int fail[maxn];
int x, y, n;
char s1[105], s2[105], vir[105];
void init() {
  fail[0] = fail[1] = 0;
  for (int i = 1; i < n; i++) {
    int j = fail[i];
    while (j != 0 and vir[i] != vir[j]) j = fail[j];
    fail[i + 1] = (vir[i] == vir[j] ? j + 1 : 0);
  }
}
void kmp() {
  init();
  for (int i = 0; i < n; i++) ch[i][vir[i] - 'A'] = i + 1;
  for (int i = 0; i < n; i++)
    for (int c = 0; c < 26; c++)
      if (ch[i][c] == 0) ch[i][c] = ch[fail[i]][c];
}
int dfs(int i, int j, int k) {
  if (vis[i][j][k]) return dp[i][j][k];
  vis[i][j][k] = true;
  if (k >= n) return dp[i][j][k] = -inf;
  if (i >= x or j >= y) return dp[i][j][k] = 0;
  dp[i][j][k] = max(dfs(i + 1, j, k), dfs(i, j + 1, k));
  if (s1[i] == s2[j])
    dp[i][j][k] = max(dp[i][j][k], dfs(i + 1, j + 1, ch[k][s1[i] - 'A']) + 1);
  return dp[i][j][k];
}
int main() {
  scanf("%s%s%s", s1, s2, vir);
  x = strlen(s1);
  y = strlen(s2);
  n = strlen(vir);
  kmp();
  if (dfs(0, 0, 0) != 0) {
    int i = 0, j = 0, k = 0;
    string ans;
    while (i < x and j < y) {
      if (dfs(i, j, k) == dfs(i + 1, j, k))
        i++;
      else if (dfs(i, j, k) == dfs(i, j + 1, k))
        j++;
      else {
        ans += s1[i];
        k = ch[k][s1[i] - 'A'];
        i++, j++;
      }
    }
    puts(ans.c_str());
  } else
    puts("0");
  return 0;
}