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 <class T, class first>
inline bool getbit(T a, first i) {
  T t = 1;
  return ((a & (t << i)) > 0);
}
template <class T, class first>
inline T setbit(T a, first i) {
  T t = 1;
  return (a | (t << i));
}
template <class T, class first>
inline T resetbit(T a, first i) {
  T t = 1;
  return (a & (~(t << i)));
}
template <class T, class first>
inline T togglebit(T a, first i) {
  T t = 1;
  return (a ^ (t << i));
}
template <typename T>
T POW(T B, T P) {
  if (P == 0) return 1;
  if (P & 1)
    return B * POW(B, P - 1);
  else
    return (POW(B, P / 2) * POW(B, P / 2));
}
template <typename T>
T BIGMOD(T b, T p, T m) {
  if (p == 0)
    return 1;
  else if (!(p & 1))
    return (Bigmod(b, p / 2, m) * Bigmod(b, p / 2, m)) % m;
  else
    return ((b % m) * Bigmod(b, p - 1, m)) % m;
}
template <typename T>
T Bigmod(T base, T power, T mod) {
  T ret = 1;
  while (power) {
    if (power & 1) ret = (ret * base) % mod;
    base = (base * base) % mod;
    power >>= 1;
  }
  return ret;
}
template <typename T>
T ModInverse(T number, T mod) {
  return Bigmod(number, mod - 2, mod);
}
template <typename T>
T GCD(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <typename T>
T LCM(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <typename T>
T EUCLIDE(T a, T b, T &x, T &y) {
  if (a < 0) {
    T d = euclide(-a, b, x, y);
    x = -x;
    return d;
  }
  if (b < 0) {
    T d = euclide(a, -b, x, y);
    y = -y;
    return d;
  }
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    T d = euclide(b, a % b, x, y);
    T t = x;
    x = y;
    y = t - (a / b) * y;
    return d;
  }
}
double DEG(double x) { return (180.0 * x) / ((2.0 * acos(0.0))); }
double RAD(double x) { return (x * (double)(2.0 * acos(0.0))) / (180.0); }
template <typename T>
T DIS(T x1, T y1, T x2, T y2) {
  return sqrt((double)((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
}
template <typename T>
T ANGLE(T x1, T y1, T x2, T y2) {
  return atan(double(y1 - y2) / double(x1 - x2));
}
template <typename T>
long long isLeft(T a, T b, T c) {
  return (c.x - a.x) * (b.y - a.y) - (b.x - a.x) * (c.y - a.y);
}
void P_ARR(int *ar, int a, int b) {
  if (a > b) swap(a, b);
  if (a <= b) cout << ar[a];
  for (int i = a + 1; i <= b; i++) cout << " " << ar[i];
  cout << endl;
}
int dir[9][2] = {{0, 0},  {0, -1}, {1, 0},  {0, 1},  {-1, 0},
                 {1, -1}, {1, 1},  {-1, 1}, {-1, -1}};
const int MX = 1000000;
const int MOD = 1000000007;
const int inf = 1000000000;
int getid(char ch) { return ch - 'A'; }
struct trie_node {
  int next[26];
  int fail;
  int fre;
  int ase;
  void init() { memset(next, 0, sizeof(next)); }
} trie_tree[MX];
char text[1000007], word[507];
bool isend[1000007];
char aa[107];
char bb[107];
char cc[107];
int dp[107][105][103];
int pt[107][105][103];
struct aho_corasick {
  int pos[505], res[MX];
  vector<int> vv[MX];
  int root, avail;
  void init() {
    root = avail = 1;
    for (int i = 0; i < 26; i++) trie_tree[0].next[i] = root;
    memset(trie_tree[root].next, 0, sizeof trie_tree[root].next);
  }
  void insert(char *s, int id) {
    int cur = root, no;
    for (int i = 0; s[i]; i++) {
      no = getid(s[i]);
      int &ret = trie_tree[cur].next[no];
      if (ret == 0) {
        ret = ++avail;
        trie_tree[ret].init();
      }
      cur = ret;
    }
    isend[cur] = true;
  }
  void failure() {
    queue<int> q;
    q.push(root);
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (int i = 0; i < 26; i++) {
        int &v = trie_tree[u].next[i];
        if (v) {
          trie_tree[v].fail = trie_tree[trie_tree[u].fail].next[i];
          q.push(v);
        } else
          v = trie_tree[trie_tree[u].fail].next[i];
      }
    }
  }
  int call(int pos, int x, int y) {
    if (aa[x] == 0 || bb[y] == 0) return 0;
    int &ret = dp[pos][x][y];
    if (ret != -1) return ret;
    if (aa[x] == bb[y]) {
      int no = aa[x] - 'A';
      int nps = trie_tree[pos].next[no];
      if (!isend[nps]) {
        ret = call(nps, x + 1, y + 1) + 1;
        pt[pos][x][y] = 1;
      }
    }
    int tm = call(pos, x + 1, y);
    if (tm > ret) {
      ret = tm;
      pt[pos][x][y] = 2;
    }
    tm = call(pos, x, y + 1);
    if (tm > ret) {
      ret = tm;
      pt[pos][x][y] = 3;
    }
    return ret;
  }
  void findpath(int pos, int x, int y) {
    if (aa[x] == 0 || bb[y] == 0) return;
    if (pt[pos][x][y] == 1) {
      printf("%c", aa[x]);
      findpath(trie_tree[pos].next[aa[x] - 'A'], x + 1, y + 1);
    } else if (pt[pos][x][y] == 2) {
      findpath(pos, x + 1, y);
    } else
      findpath(pos, x, y + 1);
  }
} ac;
int main() {
  int tc, cas = 1;
  char ch[10];
  int c;
  int n, w, b;
  {
    scanf("%s", aa);
    scanf("%s", bb);
    scanf("%s", word);
    ac.init();
    ac.insert(word, 1);
    ac.failure();
    memset(dp, -1, sizeof dp);
    int ans = ac.call(ac.root, 0, 0);
    if (ans) {
      ac.findpath(ac.root, 0, 0);
      puts("");
    } else {
      puts("0");
    }
  }
  return 0;
}