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 double INF = 1LL << 60, EPS = 1LL >> 60;
template <class T>
T pw(T a, long long b) {
  return b ? pw(a * a, b / 2) * (b % 2 ? a : (T)1) : 1;
}
long long in() {
  char c;
  bool g = false;
  while (c = getchar(), c < '0' || c > '9')
    if (c == '-')
      g = true;
    else
      g = false;
  long long x = 0;
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - 48;
    c = getchar();
  }
  return g ? -x : x;
}
void out(long long x) {
  long long len = 0, data[20];
  while (x) {
    data[len++] = x % 10;
    x /= 10;
  }
  if (!len) data[len++] = 0;
  if (data[0] != abs(data[0])) putchar('-');
  while (len--) putchar(abs(data[len]) + 48);
  putchar('\n');
}
void out(string s) {
  long long len = 0;
  while (len++ < s.size()) putchar(s[len - 1]);
  putchar('\n');
}
long long f[110], nxt[110][30];
string dp[110][110][110];
int main() {
  string s, t, v, ans;
  cin >> s >> t >> v;
  f[0] = -1;
  f[1] = 0;
  for (long long i = 2; i <= v.size(); i++) {
    long long j = f[i - 1];
    while (v[j] - v[i - 1] && j >= 0) j = f[j];
    f[i] = j + 1;
  }
  for (long long i = 0; i <= v.size(); i++)
    for (char j = 'A'; j <= 'Z'; j++) {
      if (v[i] == j)
        nxt[i][j - 'A'] = i + 1;
      else {
        long long k = f[i];
        while (v[k] - j && k >= 0) k = f[k];
        nxt[i][j - 'A'] = k + 1;
      }
    }
  for (int i = 0; i <= s.size(); i++)
    for (int j = 0; j <= t.size(); j++)
      for (int k = 0; k < v.size(); k++) {
        if (i == s.size() && j == t.size() && ans.size() < dp[i][j][k].size())
          ans = dp[i][j][k];
        else {
          if (s[i] == t[j] &&
              dp[i + 1][j + 1][nxt[k][s[i] - 'A']].size() <= dp[i][j][k].size())
            dp[i + 1][j + 1][nxt[k][s[i] - 'A']] = dp[i][j][k] + s[i];
          if (dp[i + 1][j][k].size() < dp[i][j][k].size())
            dp[i + 1][j][k] = dp[i][j][k];
          if (dp[i][j + 1][k].size() < dp[i][j][k].size())
            dp[i][j + 1][k] = dp[i][j][k];
        }
      }
  if (ans != "")
    cout << ans << '\n';
  else
    cout << 0 << '\n';
  return 0;
}