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 int INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;
string s1, s2, s3;
int p[222];
int f[111][111][111];
int path[111][111][111][3];
char show[111][111][111];
int n, m;
void update(int i, int j, int k, int oi, int oj, int ok, char p, int now) {
  if (f[i][j][k] >= now) return;
  f[i][j][k] = now;
  path[i][j][k][0] = oi;
  path[i][j][k][1] = oj;
  path[i][j][k][2] = ok;
  show[i][j][k] = p;
}
void print(int i, int j, int k) {
  if (i == 0 && j == 0) return;
  print(path[i][j][k][0], path[i][j][k][1], path[i][j][k][2]);
  if (show[i][j][k] != ' ') cout << show[i][j][k];
}
int main() {
  cin >> s1 >> s2 >> s3;
  m = s3.size();
  int j = 0;
  p[1] = 0;
  for (int i = 2; i <= m; ++i) {
    while (j && s3[j] != s3[i - 1]) j = p[j];
    if (s3[j] == s3[i - 1]) ++j;
    p[i] = j;
  }
  memset(f, -1, sizeof(f));
  f[0][0][0] = 0;
  for (int i = 0; i <= s1.size(); ++i)
    for (int j = 0; j <= s2.size(); ++j)
      for (int k = 0; k < m; ++k) {
        if (f[i][j][k] == -1) continue;
        if (i < s1.size() && j < s2.size() && s1[i] == s2[j]) {
          int l = k;
          while (l && s3[l] != s1[i]) l = p[l];
          if (s3[l] == s1[i]) ++l;
          if (l != m) update(i + 1, j + 1, l, i, j, k, s1[i], f[i][j][k] + 1);
        }
        update(i + 1, j, k, i, j, k, ' ', f[i][j][k]);
        update(i, j + 1, k, i, j, k, ' ', f[i][j][k]);
        update(i + 1, j + 1, k, i, j, k, ' ', f[i][j][k]);
      }
  int ans = 0;
  for (int i = 0; i < m; ++i) ans = max(ans, f[s1.size()][s2.size()][i]);
  if (!ans) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < m; ++i)
    if (f[s1.size()][s2.size()][i] == ans) {
      print(s1.size(), s2.size(), i);
      return 0;
    }
}