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 = 205;
const int K = 128;
int node, n, m, k;
string a, b, vir;
int Next[K][N], fail[N], pre[K][N];
int dp[102][102][102];
bool endMark[N], vis[N];
int cal(int x, int y, int ver) {
  if (x == n || y == m) return dp[x][y][ver] = 0;
  if (dp[x][y][ver] != -1) return dp[x][y][ver];
  int res = 0;
  if (a[x] == b[y]) {
    res = max(cal(x + 1, y, ver), cal(x, y + 1, ver));
    int id = a[x];
    int v = pre[id][ver];
    if (!endMark[v]) res = max(res, 1 + cal(x + 1, y + 1, v));
  } else {
    res = max(cal(x + 1, y, ver), cal(x, y + 1, ver));
  }
  return dp[x][y][ver] = res;
}
void Insert(string s) {
  int v = 0;
  for (int i = 0; i < s.size(); i++) {
    int id = s[i];
    if (!vis[Next[id][v]]) {
      Next[id][v] = ++node;
      vis[node] = true;
    }
    v = Next[id][v];
  }
  endMark[v] = true;
}
void build_fail() {
  queue<int> q;
  for (int id = 0; id < K; id++) {
    if (vis[Next[id][0]]) {
      pre[id][0] = Next[id][0];
      q.push(Next[id][0]);
    } else
      pre[id][0] = 0;
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int id = 0; id < K; id++) {
      int v = Next[id][u];
      if (!v) {
        pre[id][u] = pre[id][fail[u]];
        continue;
      }
      pre[id][u] = Next[id][u];
      q.push(v);
      fail[v] = pre[id][fail[u]];
      endMark[v] |= endMark[fail[v]];
    }
  }
}
int main() {
  int i, j, x, y, z, q, t, v;
  string s;
  memset(dp, -1, sizeof dp);
  cin >> a >> b >> vir;
  Insert(vir);
  build_fail();
  n = a.size(), m = b.size(), k = vir.size();
  x = cal(0, 0, 0);
  if (x == 0) {
    cout << 0 << endl;
    return 0;
  }
  i = 0, j = 0, v = 0;
  while (i < n && j < m) {
    if (a[i] == b[j]) {
      q = a[i];
      t = pre[q][v];
      y = max(dp[i][j + 1][v], dp[i + 1][j][v]);
      if (endMark[t] == 0 && y <= dp[i + 1][j + 1][t]) {
        s += a[i];
        i++;
        j++;
        v = t;
      } else if (dp[i][j + 1][v] < dp[i + 1][j][v])
        i++;
      else
        j++;
    } else if (dp[i][j + 1][v] < dp[i + 1][j][v])
      i++;
    else
      j++;
  }
  cout << s << endl;
  return 0;
}