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;
char s1[110], s2[110], s[110];
int l1, l2, ls, p[110][110];
int f[110][110][110], pre[110][110][110];
void dfs(int a, int b, int ans) {
  if (pre[a][b][ans] == -1) return;
  if (pre[a][b][ans] == -2)
    dfs(a - 1, b, ans);
  else if (pre[a][b][ans] == -3)
    dfs(a, b - 1, ans);
  else {
    dfs(a - 1, b - 1, pre[a][b][ans]);
    printf("%c", s1[a]);
  }
}
int main() {
  scanf("%s%s%s", s1 + 1, s2 + 1, s + 1);
  l1 = strlen(s1 + 1);
  l2 = strlen(s2 + 1);
  ls = strlen(s + 1);
  for (int i = 1; i <= ls; i++)
    for (int j = 0; j < 26; j++)
      if (s[p[i - 1][s[i] - 'A'] + 1] - 'A' == j)
        p[i][j] = p[i - 1][s[i] - 'A'] + 1;
  memset(pre, -1, sizeof pre);
  for (int i = 0; i <= l1; i++)
    for (int j = 0; j <= l2; j++)
      for (int k = 0; k < ls; k++) {
        if (f[i + 1][j][k] < f[i][j][k]) {
          f[i + 1][j][k] = f[i][j][k];
          pre[i + 1][j][k] = -2;
        }
        if (f[i][j + 1][k] < f[i][j][k]) {
          f[i][j + 1][k] = f[i][j][k];
          pre[i][j + 1][k] = -3;
        }
        if (s1[i + 1] == s2[j + 1]) {
          int t;
          if (s1[i + 1] == s[k + 1])
            t = k + 1;
          else
            t = p[k][s1[i + 1] - 'A'];
          if (f[i + 1][j + 1][t] <= f[i][j][k]) {
            f[i + 1][j + 1][t] = f[i][j][k] + 1;
            pre[i + 1][j + 1][t] = k;
          }
        }
      }
  int ans = 0;
  for (int i = 1; i < ls; i++)
    if (f[l1][l2][i] > f[l1][l2][ans]) ans = i;
  if (!f[l1][l2][ans])
    printf("0");
  else
    dfs(l1, l2, ans);
}