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 s1, s2, virus;
int dp[102][102][102];
int vis[102][102][102];
int F[102];
void prefix_function() {
  F[0] = 0;
  for (int i = 1; i < virus.size(); i++) {
    int j = F[i - 1];
    while (j > 0 and virus[j] != virus[i]) {
      j = F[j - 1];
    }
    if (virus[i] == virus[j]) j++;
    F[i] = j;
  }
}
int call(int a, int b, int c) {
  if (c == virus.size()) return -1e5;
  if (a == s1.size() or b == s2.size()) return 0;
  if (vis[a][b][c]) return dp[a][b][c];
  vis[a][b][c] = 1;
  int ret = 0;
  if (s1[a] == s2[b]) {
    int temp = c;
    while (temp >= 1) {
      if (s1[a] == virus[temp]) {
        break;
      } else {
        temp = F[temp - 1];
      }
    }
    if (s1[a] == virus[temp])
      ret = max(ret, 1 + call(a + 1, b + 1, temp + 1));
    else
      ret = max(ret, 1 + call(a + 1, b + 1, 0));
  }
  ret = max(ret, call(a + 1, b, c));
  ret = max(ret, call(a, b + 1, c));
  return dp[a][b][c] = ret;
}
void rec(int a, int b, int c) {
  if (c == virus.size()) return;
  if (a == s1.size() or b == s2.size()) return;
  if (s1[a] == s2[b]) {
    int temp = c;
    while (temp >= 1) {
      if (s1[a] == virus[temp]) {
        break;
      } else {
        temp = F[temp - 1];
      }
    }
    if (s1[a] == virus[temp]) {
      if (call(a, b, c) == 1 + call(a + 1, b + 1, temp + 1)) {
        cout << s1[a];
        rec(a + 1, b + 1, temp + 1);
        return;
      }
    } else {
      if (call(a, b, c) == 1 + call(a + 1, b + 1, 0)) {
        cout << s1[a];
        rec(a + 1, b + 1, 0);
        return;
      }
    }
  }
  if (call(a, b, c) == call(a + 1, b, c)) {
    rec(a + 1, b, c);
    return;
  }
  if (call(a, b, c) == call(a, b + 1, c)) {
    rec(a, b + 1, c);
    return;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cin >> s1 >> s2 >> virus;
  prefix_function();
  if (call(0, 0, 0))
    rec(0, 0, 0);
  else
    cout << 0 << endl;
}