#include <bits/stdc++.h>   using namespace std;   const int MAXN = (107);   const int inf = (int)1e9 + 42;   struct aho_corasick {     int is_end[MAXN], link[MAXN], psz;     map<char, int> to[MAXN];     void clear() {       for (int i = 0; i < psz; i++) is_end[i] = 0, link[i] = 0, to[i].clear();       psz = 1;       is_end[0] = 1;     }     aho_corasick() {       psz = MAXN - 2;       clear();     }     void add_word(string s) {       int u = 0;       for (char c : s) {         if (!to[u].count(c)) to[u][c] = psz++;         u = to[u][c];       }       is_end[u] = 1;     }     void push_links() {       queue<int> Q;       int u, v, j;       char c;       Q.push(0);       link[0] = -1;       while (!Q.empty()) {         u = Q.front();         Q.pop();         for (auto it : to[u]) {           v = it.second;           c = it.first;           j = link[u];           while (j != -1 && !to[j].count(c)) j = link[j];           if (j != -1)             link[v] = to[j][c];           else             link[v] = 0;           Q.push(v);         }       }     }   };   int n, m;   string s1, s2, virus;   void read() {     cin >> s1;     cin >> s2;     cin >> virus;     n = s1.size();     m = s2.size();   }   aho_corasick aho;   bool is_bad[MAXN];   int dp[MAXN][MAXN][MAXN];   int nxt_i[MAXN][MAXN][MAXN];   int nxt_j[MAXN][MAXN][MAXN];   int nxt_state[MAXN][MAXN][MAXN];   int rec(int i, int j, int state) {     if (i >= n + 1) return -inf;     if (j >= m + 1) return -inf;     if (is_bad[state]) return -inf;     if (i == n && j == m) return 0;     int &memo = dp[i][j][state];     if (memo != -1) return memo;     memo = -inf;     if (i < n && j < m && s1[i] == s2[j]) {       int u = state;       while (u != -1 && !aho.to[u].count(s1[i])) u = aho.link[u];       if (u == -1)         u = 0;       else         u = aho.to[u][s1[i]];       memo = max(memo, 1 + rec(i + 1, j + 1, u));       nxt_state[i][j][state] = u;       nxt_i[i][j][state] = i + 1;       nxt_j[i][j][state] = j + 1;     }     if (memo < rec(i + 1, j, state)) {       memo = max(memo, rec(i + 1, j, state));       nxt_state[i][j][state] = state;       nxt_i[i][j][state] = i + 1;       nxt_j[i][j][state] = j;     }     if (memo < rec(i, j + 1, state)) {       memo = max(memo, rec(i, j + 1, state));       nxt_state[i][j][state] = state;       nxt_i[i][j][state] = i;       nxt_j[i][j][state] = j + 1;     }     return memo;   }   void solve() {     aho.clear();     aho.add_word(virus);     aho.push_links();     int u = 0;     for (char c : virus) u = aho.to[u][c];     is_bad[u] = true;     for (int i = 0; i < aho.psz; i++) {       int u = i;       while (u != -1) {         is_bad[i] |= is_bad[u];         u = aho.link[u];       }     }     memset(dp, -1, sizeof(dp));     int ret = rec(0, 0, 0);     if (!ret)       cout << 0 <<   n ;     else {       string ans =   ;       int c_i = 0, c_j = 0, c_state = 0, last_i, last_j, last_state;       while (!(c_i == n && c_j == m)) {         last_i = c_i;         last_j = c_j;         last_state = c_state;         c_i = nxt_i[last_i][last_j][last_state];         c_j = nxt_j[last_i][last_j][last_state];         c_state = nxt_state[last_i][last_j][last_state];         if (c_i - last_i && c_j - last_j) ans.push_back(s1[last_i]);       }       cout << ans <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     read();     solve();     return 0;   }   