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 inf = 1000000000;
string s, ss, t;
int func[200][30];
int dp[200][200][200];
inline int go(int pos1, int pos2, int state) {
  if (state == (int)t.size()) return -inf;
  if (pos1 == (int)s.size() || pos2 == (int)ss.size()) return 0;
  int &ret = dp[pos1][pos2][state];
  if (ret != -1) return ret;
  ret = max(go(pos1 + 1, pos2, state), go(pos1, pos2 + 1, state));
  if (s[pos1] == ss[pos2])
    ret = max(ret, go(pos1 + 1, pos2 + 1, func[state][s[pos1] - 'A']) + 1);
  return ret = max(ret, 0);
}
inline void print(int pos1, int pos2, int state) {
  if (pos1 == (int)s.size() || pos2 == (int)ss.size()) return;
  int &ret = dp[pos1][pos2][state];
  if (ret == 0) return;
  if (go(pos1 + 1, pos2, state) == ret) {
    print(pos1 + 1, pos2, state);
    return;
  } else if (go(pos1, pos2 + 1, state) == ret) {
    print(pos1, pos2 + 1, state);
    return;
  }
  cout << s[pos1];
  print(pos1 + 1, pos2 + 1, func[state][s[pos1] - 'A']);
}
int main() {
  cin >> s >> ss >> t;
  func[0][t[0] - 'A'] = 1;
  for (int x = 0, j = 1; j < t.size(); j++) {
    for (char c = 'A'; c <= 'Z'; c++) func[j][c - 'A'] = func[x][c - 'A'];
    func[j][t[j] - 'A'] = j + 1;
    x = func[x][t[j] - 'A'];
  }
  memset(dp, -1, sizeof dp);
  int temp = go(0, 0, 0);
  if (temp == 0)
    cout << 0 << endl;
  else {
    print(0, 0, 0);
    cout << endl;
  }
  return 0;
}