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 next1[305][30], next2[305][30], next3[305][30];
int dp[110][110][30], nA, nB, nC;
string A, B, C;
int func(int a, int b, int c) {
  if (dp[a][b][c] != -1) return dp[a][b][c];
  int ans = 0;
  for (int i = 0; i < 26; i++) {
    int a2 = next1[a][i];
    int b2 = next2[b][i];
    int c2 = next3[c][i];
    if (a2 != -1 && b2 != -1 && c2 != -1) ans = max(ans, func(a2, b2, c2) + 1);
  }
  return dp[a][b][c] = ans;
}
int search(string s) {
  for (int i = s.size(); i >= 0; i--) {
    bool match = true;
    for (int j = 0; j < i; j++)
      if (s[s.size() - i + j] != C[j]) match = false;
    if (match) {
      if (i == nC)
        return -1;
      else
        return i;
    }
  }
}
string construct(int a, int b, int c) {
  if (dp[a][b][c] == 0) return "";
  for (int i = 0; i < 26; i++) {
    int a2 = next1[a][i];
    int b2 = next2[b][i];
    int c2 = next3[c][i];
    if (a2 != -1 && b2 != -1 && c2 != -1)
      if (dp[a][b][c] == dp[a2][b2][c2] + 1)
        return (char)('A' + i) + construct(a2, b2, c2);
  }
}
int main() {
  cin >> A >> B >> C;
  nA = A.size(), nB = B.size(), nC = C.size();
  memset(next1, -1, sizeof(next1));
  for (int i = nA - 1; i >= 0; i--)
    for (int j = 0; j < 26; j++)
      if (A[i] == 'A' + j)
        next1[i][j] = i + 1;
      else
        next1[i][j] = next1[i + 1][j];
  memset(next2, -1, sizeof(next2));
  for (int i = nB - 1; i >= 0; i--)
    for (int j = 0; j < 26; j++)
      if (B[i] == 'A' + j)
        next2[i][j] = i + 1;
      else
        next2[i][j] = next2[i + 1][j];
  memset(next3, -1, sizeof(next3));
  for (int i = 0; i < nC; i++)
    for (int j = 0; j < 26; j++)
      next3[i][j] = search(C.substr(0, i) + (char)('A' + j));
  memset(dp, -1, sizeof(dp));
  int ans = func(0, 0, 0);
  if (ans == 0)
    cout << 0 << endl;
  else
    cout << construct(0, 0, 0) << endl;
  return 0;
}