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 s1, s2, v;
int tt[200][30];
int go(int u, char p) {
  if (tt[u][p - 'A'] != -1) return tt[u][p - 'A'];
  int ans = 0;
  for (int i = 0; i < u; i++) {
    string s;
    for (int j = u - i; j <= u - 1; j++) s += v[j];
    s += p;
    for (int i = 0; i < v.size(); i++) {
      if (s[i] != v[i]) {
        if (i >= s.size()) {
          ans = max(ans, (int)s.size());
        }
        break;
      }
    }
  }
  return tt[u][p - 'A'] = ans;
}
int dp[200][200][200];
int sol[200][200][200];
int run(int i, int j, int u) {
  if (dp[i][j][u] != -1) return dp[i][j][u];
  if (u == v.size()) return -500;
  if (i > s1.size()) return -500;
  if (j > s2.size()) return -500;
  if (i == s1.size() && j == s2.size()) return 0;
  if (s1[i] == s2[j]) {
    if (v[u] == s1[i]) {
      dp[i][j][u] = max(1 + run(i + 1, j + 1, u + 1),
                        max(run(i, j + 1, u), run(i + 1, j, u)));
      if (dp[i][j][u] == 1 + run(i + 1, j + 1, u + 1))
        sol[i][j][u] = 0;
      else if (dp[i][j][u] == run(i + 1, j, u))
        sol[i][j][u] = 1;
      else
        sol[i][j][u] = 2;
    } else {
      int now = go(u, s1[i]);
      dp[i][j][u] = max(1 + run(i + 1, j + 1, now),
                        max(run(i + 1, j, u), run(i, j + 1, u)));
      if (dp[i][j][u] == 1 + run(i + 1, j + 1, now))
        sol[i][j][u] = 0;
      else if (dp[i][j][u] == run(i + 1, j, u))
        sol[i][j][u] = 1;
      else
        sol[i][j][u] = 2;
    }
  } else {
    dp[i][j][u] = max(run(i + 1, j, u), run(i, j + 1, u));
    if (dp[i][j][u] == run(i + 1, j, u))
      sol[i][j][u] = 1;
    else
      sol[i][j][u] = 2;
  }
  return dp[i][j][u];
}
int main() {
  memset(tt, -1, sizeof tt);
  memset(dp, -1, sizeof dp);
  cin >> s1 >> s2 >> v;
  int mx = run(0, 0, 0);
  if (mx == 0) {
    cout << mx;
    return 0;
  }
  int i, j, u;
  i = j = u = 0;
  while (mx) {
    if (sol[i][j][u] == 0) {
      cout << s1[i];
      mx--;
      if (s1[i] == v[u]) {
        u++;
      } else
        u = go(u, s1[i]);
      ;
      i++, j++;
    } else if (sol[i][j][u] == 1)
      i += 1;
    else
      j += 1;
  }
}