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 int N = 110;
struct State {
  int i, j, s;
  char p;
  State() {}
  State(int i, int j, int s, char p) : i(i), j(j), s(s), p(p) {}
};
char a[N], b[N], v[N];
int n, m, k;
int fail[N];
int trans[N][26];
int dp[N][N][N];
State pre[N][N][N];
void make_fail() {
  trans[0][v[1] - 'A'] = 1;
  for (int i = 1; i <= k; ++i) {
    for (int j = 0; j < 26; ++j) {
      if (i + 1 <= k and j == v[i + 1] - 'A') {
        fail[i + 1] = trans[fail[i]][j];
        trans[i][j] = i + 1;
      } else
        trans[i][j] = trans[fail[i]][j];
    }
  }
}
inline void go(int i, int j, int s, int _i, int _j, int _s, int inc, char p) {
  if (dp[i][j][s] < dp[_i][_j][_s] + inc) {
    dp[i][j][s] = dp[_i][_j][_s] + inc;
    pre[i][j][s] = State(_i, _j, _s, p);
  }
}
void DP() {
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i <= n; ++i) dp[i][0][0] = 0;
  for (int i = 0; i <= m; ++i) dp[0][i][0] = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      if (a[i] == b[j]) {
        for (int u = 0; u < k; ++u)
          if (dp[i - 1][j - 1][u] != -1 and trans[u][a[i] - 'A'] != k)
            go(i, j, trans[u][a[i] - 'A'], i - 1, j - 1, u, 1, a[i]);
      }
      for (int u = 0; u < k; ++u) {
        if (dp[i - 1][j][u] > dp[i][j - 1][u])
          go(i, j, u, i - 1, j, u, 0, '#');
        else
          go(i, j, u, i, j - 1, u, 0, '#');
      }
    }
  int ans = 0;
  for (int i = 0; i < k; ++i)
    if (dp[n][m][ans] < dp[n][m][i]) ans = i;
  if (dp[n][m][ans] <= 0)
    puts("0");
  else {
    string out = "";
    int sn = n, sm = m, s = ans;
    while (sn and sm) {
      int tn = pre[sn][sm][s].i, tm = pre[sn][sm][s].j, ts = pre[sn][sm][s].s;
      if (pre[sn][sm][s].p != '#') out += pre[sn][sm][s].p;
      sn = tn, sm = tm, s = ts;
    }
    reverse(out.begin(), out.end());
    cout << out << endl;
  }
}
int main() {
  scanf("%s %s %s", a + 1, b + 1, v + 1);
  n = strlen(a + 1), m = strlen(b + 1), k = strlen(v + 1);
  make_fail();
  DP();
  return 0;
}