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
#include <bits/stdc++.h>
const int N = 100 + 10;
int dp[N][N][N];
int pre[N][N][N][3];
char s1[N], s2[N], vir[N];
int next[N];
char ans[N];
void makeNext(int n) {
  next[0] = -1;
  int i = 0, j = -1;
  while (i < n) {
    if (j == -1 || vir[i] == vir[j]) {
      i++;
      j++;
      next[i] = j;
    } else
      j = next[j];
  }
}
void DP(int x, int y, int z, int x1, int y1, int z1, int val) {
  if (dp[x][y][z] < dp[x1][y1][z1] + val) {
    dp[x][y][z] = dp[x1][y1][z1] + val;
    pre[x][y][z][0] = x1;
    pre[x][y][z][1] = y1;
    pre[x][y][z][2] = z1;
  }
}
int main() {
  int i, j, k;
  scanf("%s%s%s", s1 + 1, s2 + 1, vir);
  int len1 = strlen(s1 + 1);
  int len2 = strlen(s2 + 1);
  int len3 = strlen(vir);
  memset(dp, 0, sizeof(dp));
  memset(pre, -1, sizeof(pre));
  makeNext(len3);
  for (i = 1; i <= len1; ++i)
    for (j = 1; j <= len2; ++j) {
      for (k = 0; k < len3; ++k) {
        DP(i, j, k, i - 1, j, k, 0);
        DP(i, j, k, i, j - 1, k, 0);
        if (s1[i] == s2[j]) {
          if (s1[i] == vir[k]) {
            DP(i, j, k + 1, i - 1, j - 1, k, 1);
          } else {
            int p = next[k];
            while (p != -1 && s1[i] != vir[p]) p = next[p];
            if (p == -1) p = 0;
            if (s1[i] == vir[p])
              DP(i, j, p + 1, i - 1, j - 1, k, 1);
            else
              DP(i, j, p, i - 1, j - 1, k, 1);
          }
        }
      }
    }
  int z;
  int Max = -1;
  for (k = 0; k < len3; ++k)
    if (Max < dp[len1][len2][k]) {
      Max = dp[len1][len2][k];
      z = k;
    }
  if (Max <= 0)
    printf("0\n");
  else {
    int tMax = Max;
    int x = len1, y = len2;
    while (pre[x][y][z][0] != -1) {
      int xx = pre[x][y][z][0];
      int yy = pre[x][y][z][1];
      int zz = pre[x][y][z][2];
      if (x - xx == 1 && y - yy == 1 && s1[x] == s2[y]) ans[Max--] = s1[x];
      x = xx;
      y = yy;
      z = zz;
    }
    for (i = 1; i <= tMax; ++i) printf("%c", ans[i]);
    printf("\n");
  }
}
