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 Fi() {
  freopen(
      "LuckyCommonSubsequence"
      ".inp",
      "r", stdin);
  freopen(
      "LuckyCommonSubsequence"
      ".out",
      "w", stdout);
}
string s1, s2, virus;
int n, m, p;
void Enter() {
  cin >> s1 >> s2 >> virus;
  n = s1.length();
  m = s2.length();
  p = virus.length();
  s1 = " " + s1;
  s2 = " " + s2;
}
int lps[111];
void ComputeLPSArray() {
  lps[0] = -1;
  int k = -1;
  int i = 0;
  while (i < p) {
    while (k != -1 && virus[i] != virus[k]) {
      k = lps[k];
    }
    lps[++i] = ++k;
  }
}
int dp[111][111][111];
struct data {
  int x, y, z;
};
data trace[111][111][111];
void Process() {
  ComputeLPSArray();
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      for (int k = 0; k < p; ++k) {
        if (dp[i][j][k] < dp[i - 1][j][k]) {
          dp[i][j][k] = dp[i - 1][j][k];
          trace[i][j][k] = {i - 1, j, k};
        }
        if (dp[i][j][k] < dp[i][j - 1][k]) {
          dp[i][j][k] = dp[i][j - 1][k];
          trace[i][j][k] = {i, j - 1, k};
        }
        if (s1[i] == s2[j]) {
          int x = k;
          while (x != -1 && s1[i] != virus[x]) {
            x = lps[x];
          }
          if (dp[i][j][x + 1] < dp[i - 1][j - 1][k] + 1) {
            dp[i][j][x + 1] = dp[i - 1][j - 1][k] + 1;
            trace[i][j][x + 1] = {i - 1, j - 1, k};
          }
        }
      }
    }
  }
  int ans = 0;
  data now;
  for (int k = 0; k < p; ++k) {
    if (ans < dp[n][m][k]) {
      ans = dp[n][m][k];
      now = {n, m, k};
    }
  }
  if (!ans) {
    cout << ans;
  } else {
    string s = "";
    int x = now.x, y = now.y, z = now.z, xx, yy, zz;
    while (1 <= x && 1 <= y) {
      xx = trace[x][y][z].x;
      yy = trace[x][y][z].y;
      zz = trace[x][y][z].z;
      if (ans > 0 && xx < x && yy < y) {
        s = s1[x] + s;
        --ans;
      }
      x = xx;
      y = yy;
      z = zz;
    }
    cout << s;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  Enter();
  Process();
  return 0;
}