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 dp[102][102][102];
int state[102][102][102];
string s1, s2, virus;
int n1, n2, n3;
vector<int> fail;
vector<int> failF() {
  vector<int> T(102, -1);
  for (int i = 1; i <= virus.length(); i++) {
    int pos = T[i - 1];
    while (pos != -1 && virus.at(pos) != virus.at(i - 1)) pos = T[pos];
    T[i] = pos + 1;
  }
  return T;
}
int z = 1;
int dpM(int i1, int i2, int i3) {
  if (dp[i1][i2][i3] != -1) return dp[i1][i2][i3];
  int sol = dpM(i1 + 1, i2, i3);
  state[i1][i2][i3] = -1;
  int temp = dpM(i1, i2 + 1, i3);
  if (temp > sol) {
    sol = temp;
    state[i1][i2][i3] = -2;
  }
  if (s1.at(i1) == s2.at(i2)) {
    int d = i3;
    while (d >= 0 && s1.at(i1) != virus.at(d)) {
      d = fail[d];
      z++;
    }
    d++;
    temp = 1 + dpM(i1 + 1, i2 + 1, d);
    if (temp > sol) {
      sol = temp;
      state[i1][i2][i3] = d;
    }
  }
  return dp[i1][i2][i3] = sol;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> s1 >> s2 >> virus;
  n1 = s1.length();
  n2 = s2.length();
  n3 = virus.length();
  fail = failF();
  memset(dp, 0xff, sizeof(dp));
  for (int i = 0; i <= n1; i++) {
    for (int j = 0; j <= n2; j++) dp[i][j][n3] = -1000000000;
  }
  for (int i = 0; i <= n1; i++) {
    for (int k = 0; k < n3; k++) dp[i][n2][k] = 0;
  }
  for (int j = 0; j <= n2; j++) {
    for (int k = 0; k < n3; k++) dp[n1][j][k] = 0;
  }
  int ans = dpM(0, 0, 0);
  if (ans <= 0)
    cout << 0 << '\n';
  else {
    int i1 = 0, i2 = 0, i3 = 0, c = 0;
    while (c < ans) {
      switch (state[i1][i2][i3]) {
        case -1:
          i1++;
          break;
        case -2:
          i2++;
          break;
        default:
          cout << s1.at(i1);
          i3 = state[i1][i2][i3];
          i1++;
          i2++;
          c++;
      }
    }
  }
  return 0;
}