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], vr[110];
int tr[110][110][110], f[110][110][110], pr[110][110][110], u[110], nt[110], l1,
    l2, l3;
vector<char> al;
void ud(int k, int x, int y, int d) {
  for (int i = x; i <= l1 + 1; i += i & -i)
    for (int j = y; j <= l2 + 1; j += j & -j) tr[k][i][j] = max(tr[k][i][j], d);
}
int qy(int k, int x, int y) {
  int ans = 0;
  for (int i = x; i; i -= i & -i)
    for (int j = y; j; j -= j & -j) ans = max(ans, tr[k][i][j]);
  return ans;
}
void pre() {
  nt[0] = -1;
  for (int i = 1; i < l3; i++) {
    int j;
    for (j = nt[i - 1]; j != -1 && vr[j + 1] != vr[i]; j = nt[j])
      ;
    if (j > -1)
      nt[i] = j + 1;
    else
      nt[i] = vr[i] == vr[0] ? 0 : -1;
  }
}
int ok(int zz, int x, int z) {
  if (!zz && s1[x] != vr[z]) return 1;
  return zz && (!z || s1[x] != vr[z]);
}
int main() {
  gets(s1);
  gets(s2);
  gets(vr);
  l1 = strlen(s1), l2 = strlen(s2), l3 = strlen(vr);
  pre();
  memset(tr, 0, sizeof(tr));
  int t0, t1, t2, t3;
  memset(f, 0, sizeof(f));
  for (int i = 0; i < l1; i++)
    for (int j = 0; j < l2; j++)
      if (s1[i] == s2[j]) {
        for (int k = 0; k < l3; k++) {
          t0 = qy(k, i, j);
          if (!t0 && k) continue;
          for (t2 = k - 1; t2 != -1 && s1[i] != vr[t2 + 1]; t2 = nt[t2])
            ;
          if (t2 != -1) {
            if (t0 + 1 > f[i][j][t2 + 2]) {
              pr[i][j][t2 + 2] = k;
              f[i][j][t2 + 2] = t0 + 1;
              ud(t2 + 2, i + 1, j + 1, t0 + 1);
            }
          } else {
            if (s1[i] != vr[0])
              t3 = 0;
            else
              t3 = 1;
            if (t0 + 1 > f[i][j][t3]) {
              pr[i][j][t3] = k;
              f[i][j][t3] = t0 + 1;
              ud(t3, i + 1, j + 1, t0 + 1);
            }
          }
        }
      }
  int ans = -1, ai, aj, ak;
  for (int i = 0; i < l1; i++)
    for (int j = 0; j < l2; j++)
      for (int k = 0; k < l3; k++)
        if (f[i][j][k] > ans) {
          ans = f[i][j][k];
          ai = i;
          aj = j;
          ak = k;
        }
  int ff;
  for (int fg = 1; ans && fg;) {
    al.push_back(s1[ai]);
    if (f[ai][aj][ak] == 1) fg = 0;
    ff = 0;
    t0 = pr[ai][aj][ak];
    for (int i = 0; i < ai; i++) {
      for (int j = 0; j < aj; j++)
        if (s1[i] == s2[j] && f[i][j][t0] == f[ai][aj][ak] - 1) {
          ai = i;
          aj = j;
          ak = t0;
          ff = 1;
          break;
        }
      if (ff) break;
    }
  }
  if (!(int)al.size())
    printf("0");
  else
    for (int i = (int)al.size() - 1; i > -1; i--) printf("%c", al[i]);
  puts("");
  return 0;
}