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;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <class T>
inline void println(T first) {
  print(first);
  putchar('\n');
}
template <class T>
inline void printsp(T first) {
  print(first);
  putchar(' ');
}
template <class T1, class T2>
inline void print(T1 x1, T2 x2) {
  printsp(x1), println(x2);
}
template <class T1, class T2, class T3>
inline void print(T1 x1, T2 x2, T3 x3) {
  printsp(x1), printsp(x2), println(x3);
}
template <class T1, class T2, class T3, class T4>
inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {
  printsp(x1), printsp(x2), printsp(x3), println(x4);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int dp[111][111][111];
char s[111], t[111], v[111];
int q[111], qf = 0, qb = 0;
int used;
struct node {
  int nxt[27], fail, cnt;
  void clear() {
    memset(nxt, -1, sizeof nxt);
    fail = -1;
    cnt = 0;
  }
} mem[111];
struct AC_automaton {
  int newnode() {
    int ans = ++used;
    mem[ans].clear();
    return ans;
  }
  void init() {
    used = -1;
    newnode();
    qb = qf = 0;
  }
  void insert(char *s) {
    int now = 0;
    for (int i = 0; s[i]; i++) {
      if (mem[now].nxt[s[i] - 'A'] == -1) mem[now].nxt[s[i] - 'A'] = newnode();
      now = mem[now].nxt[s[i] - 'A'];
    }
    mem[now].cnt++;
    return;
  }
  void build() {
    mem[0].fail = 0;
    for (int i = 0; i < 26; i++) {
      if (mem[0].nxt[i] == -1) {
        mem[0].nxt[i] = 0;
      } else {
        mem[mem[0].nxt[i]].fail = 0;
        q[qb++] = mem[0].nxt[i];
      }
    }
    while (qb > qf) {
      int u = q[qf++];
      mem[u].cnt += mem[mem[u].fail].cnt;
      for (int i = 0; i < 26; i++) {
        if (mem[u].nxt[i] == -1) {
          mem[u].nxt[i] = mem[mem[u].fail].nxt[i];
        } else {
          mem[mem[u].nxt[i]].fail = mem[mem[u].fail].nxt[i];
          q[qb++] = mem[u].nxt[i];
        }
      }
    }
  }
} ac;
pair<pair<int, int>, int> pre[111][111][111];
char res[111];
int main() {
  cin >> s + 1 >> t + 1 >> v + 1;
  int n = strlen(s + 1), m = strlen(t + 1);
  ac.init();
  ac.insert(v + 1);
  ac.build();
  memset(dp, -1, sizeof dp);
  dp[0][0][0] = 0;
  int ans = 0, u, v, d;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      for (int k = 0; k < used; k++)
        if (~dp[i][j][k]) {
          if (k < used) {
            if (dp[i][j][k] > ans) ans = dp[i][j][k], u = i, v = j, d = k;
          }
          if (dp[i + 1][j][k] < dp[i][j][k]) {
            dp[i + 1][j][k] = dp[i][j][k];
            pre[i + 1][j][k] =
                pair<pair<int, int>, int>(pair<int, int>(i, j), k);
          }
          if (dp[i][j + 1][k] < dp[i][j][k]) {
            dp[i][j + 1][k] = dp[i][j][k];
            pre[i][j + 1][k] =
                pair<pair<int, int>, int>(pair<int, int>(i, j), k);
          }
          if (s[i + 1] == t[j + 1]) {
            int first = mem[k].nxt[s[i + 1] - 'A'];
            if (dp[i + 1][j + 1][first] < dp[i][j][k] + 1) {
              dp[i + 1][j + 1][first] = dp[i][j][k] + 1;
              pre[i + 1][j + 1][first] =
                  pair<pair<int, int>, int>(pair<int, int>(i, j), k);
            }
          }
        }
    }
  }
  if (ans == 0) return puts("0");
  res[ans] = 0;
  while (ans--) {
    int uu = pre[u][v][d].first.first;
    int vv = pre[u][v][d].first.second;
    int dd = pre[u][v][d].second;
    if (u != uu and v != vv)
      res[ans] = s[u];
    else
      ans++;
    u = uu;
    v = vv;
    d = dd;
  }
  puts(res);
  return 0;
}