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 = 100006 * 4;
vector<int> v[N];
struct node {
  int ch[N][26];
  int fail[N];
  int tot;
  int cnt[N];
  void init() {
    memset(ch[0], 0, sizeof ch[0]);
    tot = 0;
    fail[0] = cnt[0] = 0;
    tot++;
    v[0].clear();
  }
  void ins(char *str, int val) {
    int L = strlen(str);
    int rt = 0;
    for (int i = 0; i < L; i++) {
      int c = str[i] - 'A';
      if (!ch[rt][c]) {
        memset(ch[tot], 0, sizeof ch[tot]);
        ch[rt][c] = tot;
        fail[tot] = 0;
        cnt[tot] = 0;
        tot++;
        v[tot - 1].clear();
      }
      rt = ch[rt][c];
    }
    cnt[rt] = val;
  }
  void build() {
    queue<int> que;
    for (int i = 0; i < 26; i++)
      if (ch[0][i]) que.push(ch[0][i]), fail[ch[0][i]] = 0;
    while (!que.empty()) {
      int u = que.front();
      que.pop();
      for (int i = 0; i < 26; i++) {
        if (!ch[u][i]) {
          ch[u][i] = ch[fail[u]][i];
        } else {
          fail[ch[u][i]] = ch[fail[u]][i];
          que.push(ch[u][i]);
        }
      }
    }
  }
} ac;
char a[105];
char b[106];
char t[106];
string dp[105][106][106];
string maxx(string a, string b) {
  if (a.size() > b.size())
    return a;
  else
    return b;
}
struct LZ {
  int x, y, sta;
} lz[105][105][105];
int main() {
  int n;
  cin >> a + 1 >> b + 1 >> t + 1;
  int cc = strlen(t + 1);
  ac.init();
  ac.ins(t + 1, 1);
  int aa = strlen(a + 1);
  int bb = strlen(b + 1);
  ac.build();
  for (int i = 1; i <= aa; i++) {
    for (int j = 1; j <= bb; j++) {
      for (int sta = 0; sta < cc; sta++) {
        dp[i][j][sta] =
            maxx(dp[i][j][sta], maxx(dp[i - 1][j][sta], dp[i][j - 1][sta]));
        if (a[i] == b[j]) {
          dp[i][j][ac.ch[sta][a[i] - 'A']] = maxx(
              dp[i - 1][j - 1][sta] + a[i], dp[i][j][ac.ch[sta][a[i] - 'A']]);
        }
      }
    }
  }
  string ans;
  for (int i = 0; i < cc; i++) {
    ans = maxx(ans, dp[aa][bb][i]);
  }
  if (ans == "") {
    cout << 0 << endl;
    return 0;
  }
  cout << ans << endl;
}