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;
void run() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
string a, b, v;
int mem[105][105][105], f[105];
int solve(int p1, int p2, int p3) {
  if (p3 == v.size())
    return mem[p1][p2][p3] = -INT_MAX;
  else if (p1 == a.size() || p2 == b.size())
    return mem[p1][p2][p3] = 0;
  int &ret = mem[p1][p2][p3];
  int np3 = p3;
  if (ret != -1) return ret;
  ret = -INT_MAX;
  if (a[p1] == b[p2]) {
    while (p3 > 0 && a[p1] != v[p3]) p3 = f[p3 - 1];
    if (a[p1] == v[p3]) p3++;
    ret = solve(p1 + 1, p2 + 1, p3) + 1;
  }
  p3 = np3;
  ret = max(ret, solve(p1 + 1, p2, p3));
  ret = max(ret, solve(p1, p2 + 1, p3));
  return ret;
}
void build(int p1, int p2, int p3) {
  while (1) {
    if (p1 == a.size() || p2 == b.size()) break;
    int take = -INT_MAX, l1 = -INT_MAX, l2 = -INT_MAX;
    int np3 = p3;
    if (a[p1] == b[p2]) {
      while (p3 > 0 && a[p1] != v[p3]) p3 = f[p3 - 1];
      if (a[p1] == v[p3]) p3++;
      take = mem[p1 + 1][p2 + 1][p3] + 1;
    }
    l1 = mem[p1 + 1][p2][np3];
    l2 = mem[p1][p2 + 1][np3];
    if (take == mem[p1][p2][np3]) {
      cout << a[p1];
      p1++;
      p2++;
    } else if (l1 == mem[p1][p2][np3]) {
      p1++;
      p3 = np3;
    } else {
      p2++;
      p3 = np3;
    }
  }
  return;
}
void fail(string tmp) {
  f[0] = 0;
  int k = 0;
  for (int i = 1; i < tmp.size(); i++) {
    while (k > 0 && tmp[k] != tmp[i]) k = f[k - 1];
    if (tmp[k] == tmp[i])
      f[i] = ++k;
    else if (tmp[k] != tmp[i])
      f[i] = k;
  }
}
int main() {
  run();
  cin >> a >> b >> v;
  for (int i = 0; i <= a.size(); i++)
    for (int j = 0; j <= b.size(); j++)
      for (int k = 0; k <= v.size(); k++) mem[i][j][k] = -1;
  fail(v);
  int ans = solve(0, 0, 0);
  if (ans > 0)
    build(0, 0, 0);
  else
    cout << 0 << endl;
  return 0;
}