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 inf = 0x3f3f3f3f;
struct p {
  int x, y, z;
} pre[105][105][105], e;
char a[105];
char b[105];
char c[105];
int dp[105][105][105];
int nex[105];
void get_next(const char P[], int nex[]) {
  int q, k;
  int m = strlen(P);
  nex[0] = 0;
  for (q = 1, k = 0; q < m; ++q) {
    while (k > 0 && P[q] != P[k]) {
      k = nex[k - 1];
    }
    if (P[q] == P[k]) {
      k++;
    }
    nex[q] = k;
  }
  return;
}
void dfs(p t) {
  int x, y, z;
  x = t.x, y = t.y, z = t.z;
  if (x == 0 && y == 0 && z == 0) return;
  p q = pre[x][y][z];
  int i = q.x, j = q.y, k = q.z;
  dfs(q);
  if (dp[i][j][k] + 1 == dp[x][y][z]) printf("%c", a[i]);
}
int main() {
  scanf("%s%s%s", a, b, c);
  get_next(c, nex);
  memset(dp, 0, sizeof dp);
  int n = strlen(a), m = strlen(b), q = strlen(c);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) dp[i][j][0] = 0;
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      for (int k = 0; k < q; 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].x = i;
          pre[i + 1][j][k].y = j;
          pre[i + 1][j][k].z = 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].x = i;
          pre[i][j + 1][k].y = j;
          pre[i][j + 1][k].z = k;
        }
        if (a[i] == b[j]) {
          int w = k;
          while (w > 0 && a[i] != c[w]) w = nex[w - 1];
          if (a[i] == c[w])
            w++;
          else
            w = 0;
          if (dp[i + 1][j + 1][w] < dp[i][j][k] + 1) {
            dp[i + 1][j + 1][w] = dp[i][j][k] + 1;
            pre[i + 1][j + 1][w].x = i;
            pre[i + 1][j + 1][w].y = j;
            pre[i + 1][j + 1][w].z = k;
          }
        }
      }
    }
  }
  int ma = 0;
  for (int k = 0; k < q; k++) {
    if (dp[n][m][k] > ma) {
      ma = dp[n][m][k];
      e.x = n;
      e.y = m;
      e.z = k;
    }
  }
  if (ma == 0) return 0 * printf("0\n");
  dfs(e);
  return 0;
}