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 A, B, V;
vector<int> T(V.size() + 1);
int mem[110][110][110];
pair<pair<int, int>, int> nex[110][110][110];
int dp(int ia, int ib, int iv) {
  if (iv == V.size()) return -1000000000;
  if (ia == A.size() || ib == B.size()) return 0;
  if (mem[ia][ib][iv] != -1) return mem[ia][ib][iv];
  int w = -1000000000;
  if (A[ia] == B[ib]) {
    int niv = iv;
    while (niv >= 0 && V[niv] != B[ib]) niv = T[niv];
    niv++;
    int t = dp(ia + 1, ib + 1, niv) + 1;
    if (t > w) {
      nex[ia][ib][iv] =
          pair<pair<int, int>, int>(pair<int, int>(ia + 1, ib + 1), niv);
      w = t;
    }
  }
  {
    int t = dp(ia + 1, ib, iv);
    if (t > w) {
      nex[ia][ib][iv] =
          pair<pair<int, int>, int>(pair<int, int>(ia + 1, ib), iv);
      w = t;
    }
  }
  {
    int t = dp(ia, ib + 1, iv);
    if (t > w) {
      nex[ia][ib][iv] =
          pair<pair<int, int>, int>(pair<int, int>(ia, ib + 1), iv);
      w = t;
    }
  }
  return mem[ia][ib][iv] = w;
}
int main() {
  cin >> A >> B >> V;
  {
    int i = 0, j = -1;
    T[i] = j;
    while (i < V.size()) {
      while (j >= 0 && V[i] != V[j]) j = T[j];
      i++;
      j++;
      T[i] = j;
    }
  }
  memset(mem, -1, sizeof(mem));
  int t = dp(0, 0, 0);
  if (t == 0) {
    cout << t << endl;
  } else {
    int ia = 0, ib = 0, iv = 0;
    string s = "";
    int cnt = 0;
    while (iv < V.size() && ia < A.size() && ib < B.size()) {
      pair<pair<int, int>, int> n = nex[ia][ib][iv];
      if (n.first.first == ia + 1 && n.first.second == ib + 1) {
        s += A[ia];
      }
      ia = n.first.first;
      ib = n.first.second;
      iv = n.second;
    }
    cout << s << endl;
  }
}