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;
string t1, t2, v;
int l1, l2, l3;
int dp[101][101][101];
pair<int, pair<int, int> > path[101][101][101];
char ans[101][101][101];
int F[101];
void build_failure_function() {
  F[0] = F[1] = 0;
  int j;
  for (int i = 2; i <= l3; i++) {
    j = F[i - 1];
    for (;;) {
      if (v[j] == v[i - 1]) {
        F[i] = j + 1;
        break;
      }
      if (j == 0) {
        F[i] = 0;
        break;
      }
      j = F[j];
    }
  }
}
int dp2[101][27];
int getFail(int a, char c) {
  if (a == 0 || v[a] == c) return a;
  return dp2[a][c - 'a'] = getFail(F[a], c);
}
int solve(int x, int y, int z) {
  if (z == l3) {
    path[x][y][z] = make_pair(-1, make_pair(-1, -1));
    return -1e3;
  }
  if (x == l1 || y == l2) {
    path[x][y][z] = make_pair(-1, make_pair(-1, -1));
    return 0;
  }
  if (dp[x][y][z] != -1) return dp[x][y][z];
  int mx1, mx2, mx3;
  ans[x][y][z] = -1;
  if (t1[x] == t2[y])
    mx1 = 1 + solve(x + 1, y + 1,
                    (v[z] == t1[x] ? z + 1
                                   : getFail(z, t1[x]) +
                                         (v[getFail(z, t1[x])] == t1[x])));
  else
    mx1 = -1e3;
  mx2 = solve(x + 1, y, z);
  mx3 = solve(x, y + 1, z);
  if (mx1 >= mx2 && mx1 >= mx3)
    path[x][y][z] = make_pair(
        x + 1, make_pair(y + 1, (v[z] == t1[x]
                                     ? z + 1
                                     : getFail(z, t1[x]) +
                                           (v[getFail(z, t1[x])] == t1[x])))),
    ans[x][y][z] = t1[x];
  else if (mx2 >= mx1 && mx2 >= mx3)
    path[x][y][z] = make_pair(x + 1, make_pair(y, z));
  else
    path[x][y][z] = make_pair(x, make_pair(y + 1, z));
  return dp[x][y][z] = max(mx1, max(mx2, mx3));
}
bool isAlpha(char a) {
  if (a >= 'a' && a <= 'z') return true;
  if (a >= 'A' && a <= 'Z') return true;
  return false;
}
int main() {
  cin >> t1 >> t2 >> v;
  memset(dp, -1, sizeof dp);
  l1 = t1.length();
  l2 = t2.length();
  l3 = v.length();
  build_failure_function();
  int val = solve(0, 0, 0);
  if (val <= 0)
    cout << 0 << endl;
  else {
    int nxt1 = 0;
    int nxt2 = 0;
    int nxt3 = 0;
    while (nxt1 != -1) {
      int nn1 = path[nxt1][nxt2][nxt3].first;
      int nn2 = path[nxt1][nxt2][nxt3].second.first;
      int nn3 = path[nxt1][nxt2][nxt3].second.second;
      if (isAlpha(ans[nxt1][nxt2][nxt3])) cout << ans[nxt1][nxt2][nxt3];
      nxt1 = nn1, nxt2 = nn2, nxt3 = nn3;
    }
    cout << endl;
  }
  return 0;
}