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;
const int N = 110;
const int B = 26;
string a, b, virus;
int nxt[N][B];
pair<pair<int, int>, int> path[N][N][N];
int dp[N][N][N];
void print_path(int r, int c, int stat) {
  if (r == 0 && c == 0) return;
  pair<pair<int, int>, int> pre = path[r][c][stat];
  print_path(pre.first.first, pre.first.second, pre.second);
  if (pre.first.first + 1 == r && pre.first.second + 1 == c) {
    putchar(a[r - 1]);
  }
}
int main() {
  cin >> a >> b >> virus;
  for (int i = 0; i <= virus.length(); i++) {
    for (int j = 0; j < B; j++) {
      string cur = virus.substr(0, i) + char('A' + j);
      while (cur != virus.substr(0, cur.length())) cur = cur.substr(1);
      nxt[i][j] = cur.length();
    }
  }
  memset(dp, 0xc0, sizeof dp);
  dp[0][0][0] = 0;
  for (int i = 0; i <= a.length(); i++) {
    for (int j = 0; j <= b.length(); j++) {
      for (int k = 0; k < virus.length(); k++) {
        int &cur = dp[i][j][k];
        if (i + 1 <= a.length() && j + 1 <= b.length()) {
          if (a[i] == b[j]) {
            int &v = dp[i + 1][j + 1][nxt[k][a[i] - 'A']];
            if (cur + 1 > v) {
              v = cur + 1;
              path[i + 1][j + 1][nxt[k][a[i] - 'A']] =
                  make_pair(make_pair(i, j), k);
            }
          }
        }
        if (i + 1 <= a.length()) {
          int &v = dp[i + 1][j][k];
          if (cur > v) {
            v = cur;
            path[i + 1][j][k] = make_pair(make_pair(i, j), k);
          }
        }
        if (j + 1 <= b.length()) {
          int &v = dp[i][j + 1][k];
          if (cur > v) {
            v = cur;
            path[i][j + 1][k] = make_pair(make_pair(i, j), k);
          }
        }
      }
    }
  }
  int ans = 0, stat = 0;
  for (int i = 0; i < virus.length(); i++) {
    if (dp[a.length()][b.length()][i] > ans) {
      ans = dp[a.length()][b.length()][i];
      stat = i;
    }
  }
  if (ans) {
    print_path(a.length(), b.length(), stat);
    putchar(10);
  } else {
    printf("%d\n", 0);
  }
  return 0;
}