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;
int const MAX_CH = 110;
char st1[MAX_CH], st2[MAX_CH], st3[MAX_CH];
int dp[MAX_CH][MAX_CH][MAX_CH];
int new_pref_len[MAX_CH][30];
struct {
  int i, j, k;
  char ad_ch;
} from[MAX_CH][MAX_CH][MAX_CH];
int main() {
  gets(st1);
  int len_1 = (int)strlen(st1);
  gets(st2);
  int len_2 = (int)strlen(st2);
  gets(st3);
  int len_3 = (int)strlen(st3);
  for (int taked = 0; taked < len_3; taked++)
    for (int ch = 0; ch < 26; ch++) {
      string cur;
      for (int j = 0; j < taked; j++) cur += st3[j];
      cur += (char)('A' + ch);
      int mx_pref = 0;
      for (int bg = 0; bg < (int)cur.length(); bg++) {
        int Ok = 1;
        for (int r = 0; r < len_3 && bg + r < (int)cur.length(); r++)
          if (st3[r] != cur[bg + r]) {
            Ok = 0;
            break;
          }
        if (Ok) mx_pref = max(mx_pref, ((int)cur.length()) - bg);
      }
      new_pref_len[taked][ch] = mx_pref;
    }
  for (int i = 0; i < MAX_CH; i++)
    for (int j = 0; j < MAX_CH; j++)
      for (int k = 0; k < MAX_CH; k++) dp[i][j][k] = -1;
  for (int i = 0; i < MAX_CH; i++) {
    dp[i][0][0] = 0;
    dp[0][i][0] = 0;
  }
  for (int i = 1; i <= len_1; i++)
    for (int j = 1; j <= len_2; j++)
      for (int k = 0; k < len_3; k++) {
        if (st1[i - 1] == st2[j - 1]) {
          int new_k;
          if (st3[k] == st1[i - 1])
            new_k = k + 1;
          else
            new_k = new_pref_len[k][st1[i - 1] - 'A'];
          if (new_k >= len_3)
            ;
          else if (dp[i - 1][j - 1][k] + 1 > dp[i][j][new_k]) {
            dp[i][j][new_k] = dp[i - 1][j - 1][k] + 1;
            from[i][j][new_k].i = i - 1;
            from[i][j][new_k].j = j - 1;
            from[i][j][new_k].k = k;
            from[i][j][new_k].ad_ch = st1[i - 1];
          }
        }
        if (dp[i - 1][j][k] > dp[i][j][k]) {
          dp[i][j][k] = dp[i - 1][j][k];
          from[i][j][k].i = i - 1;
          from[i][j][k].j = j;
          from[i][j][k].k = k;
          from[i][j][k].ad_ch = 0;
        }
        if (dp[i][j - 1][k] > dp[i][j][k]) {
          dp[i][j][k] = dp[i][j - 1][k];
          from[i][j][k].i = i;
          from[i][j][k].j = j - 1;
          from[i][j][k].k = k;
          from[i][j][k].ad_ch = 0;
        }
      }
  int cur_i = len_1, cur_j = len_2, cur_k = -1;
  int mx = -1;
  for (int k = 0; k < len_3; k++)
    if (dp[len_1][len_2][k] > mx) {
      mx = dp[len_1][len_2][k];
      cur_k = k;
    }
  if (mx <= 0) {
    printf("0");
    return 0;
  }
  string ans;
  while (cur_i >= 1 && cur_j >= 1) {
    if (from[cur_i][cur_j][cur_k].ad_ch > 0)
      ans += from[cur_i][cur_j][cur_k].ad_ch;
    int new_i = from[cur_i][cur_j][cur_k].i;
    int new_j = from[cur_i][cur_j][cur_k].j;
    int new_k = from[cur_i][cur_j][cur_k].k;
    cur_i = new_i;
    cur_j = new_j;
    cur_k = new_k;
  }
  for (int i = ((int)ans.length()) - 1; i >= 0; i--) printf("%c", ans[i]);
  return 0;
}