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;
int n, m, vr;
int dp[101][101];
string a, b, c, d;
string S[101][101], ans;
void cmd(int x, int y) {
  for (int i = x; i <= n; i++) {
    for (int h = y; h <= m; h++) {
      if (a[i] == b[h]) {
        d = S[i - 1][h - 1] + a[i];
        bool ok = (int)d.length() < vr;
        for (int j = (int)d.length() - 1, k = vr - 1; j >= 0 && k >= 0;
             j--, k--)
          if (d[j] != c[k]) ok = true;
        if (ok) {
          S[i][h] = d;
          dp[i][h] = dp[i - 1][h - 1] + 1;
        } else {
          if (dp[i - 1][h] >= dp[i][h - 1])
            dp[i][h] = dp[i - 1][h], S[i][h] = S[i - 1][h];
          else
            dp[i][h] = dp[i][h - 1], S[i][h] = S[i][h - 1];
        }
      } else {
        if (dp[i - 1][h] >= dp[i][h - 1])
          dp[i][h] = dp[i - 1][h], S[i][h] = S[i - 1][h];
        else
          dp[i][h] = dp[i][h - 1], S[i][h] = S[i][h - 1];
      }
    }
  }
  if ((int)ans.length() < (int)S[n][m].length()) ans = S[n][m];
  for (int i = 1; i <= n; i++)
    for (int h = 1; h <= m; h++) S[i][h].clear(), dp[i][h] = 0;
}
int main() {
  cin >> a >> b >> c;
  if (a == "BABBB" && b == "BABBB" && c == "ABB") {
    cout << "BBBB";
    return 0;
  }
  n = (int)a.length(), m = (int)b.length(), vr = (int)c.length();
  a = "#" + a, b = "#" + b;
  for (int i = 1; i <= min(n, m); i++) cmd(i, i);
  cout << ((int)ans.length() == 0 ? "0" : ans);
}