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>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int N = 109;
const int inf = 0x3f3f3f3f;
const long long oo = 0x3f3f3f3f3f3f3f3fll;
char s1[N], s2[N], s0[N];
int fail[N], l1, l2, l0;
void getFail(char s[], int fail[]) {
  fail[0] = -1;
  for (int i = 1, j = -1; s[i]; i++) {
    while (j != -1 && s[j + 1] != s[i]) j = fail[j];
    if (s[j + 1] == s[i]) j++;
    fail[i] = j;
  }
}
int dp[N][N][N];
int dfs(int a, int b, int c) {
  if (c == l0) return -inf;
  if (a == l1 || b == l2) return 0;
  int &ret = dp[a][b][c];
  if (ret + 1) return ret;
  ret = 0;
  if (s1[a] == s2[b]) {
    if (s0[c] == s1[a])
      ret = max(ret, dfs(a + 1, b + 1, c + 1) + 1);
    else {
      int id = c - 1;
      while (id != -1 && s0[id + 1] != s1[a]) id = fail[id];
      if (s0[id + 1] == s1[a]) id++;
      ret = max(ret, dfs(a + 1, b + 1, id + 1) + 1);
    }
  }
  ret = max(ret, dfs(a + 1, b, c));
  ret = max(ret, dfs(a, b + 1, c));
  return ret;
}
void print(int a, int b, int c) {
  if (a == l1 || b == l2 || c == l0) {
    puts("");
    return;
  }
  int ret = dfs(a, b, c);
  if (s1[a] == s2[b]) {
    int temp = -1;
    int id = c - 1;
    if (s0[c] == s1[a])
      temp = dfs(a + 1, b + 1, c + 1) + 1, id = c + 1;
    else {
      while (id != -1 && s0[id + 1] != s1[a]) id = fail[id];
      if (s0[id + 1] == s1[a]) id++;
      temp = dfs(a + 1, b + 1, id + 1) + 1;
      id++;
    }
    if (temp == ret) {
      printf("%c", s1[a]);
      print(a + 1, b + 1, id);
      return;
    }
  }
  if (ret == dfs(a + 1, b, c)) {
    print(a + 1, b, c);
    return;
  }
  if (ret == dfs(a, b + 1, c)) {
    print(a, b + 1, c);
    return;
  }
  return;
}
int main() {
  scanf("%s%s%s", s1, s2, s0);
  l1 = strlen(s1);
  l2 = strlen(s2);
  l0 = strlen(s0);
  memset(dp, -1, sizeof(dp));
  getFail(s0, fail);
  if (dfs(0, 0, 0))
    print(0, 0, 0);
  else
    puts("0");
  return 0;
}