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 = 1 << 30;
const int maxn = 111;
struct data {
  int x, y, z;
} pre[maxn][maxn][maxn], e;
char a[maxn], b[maxn], c[maxn];
int dp[maxn][maxn][maxn], nxt[maxn];
int na, nb, nc;
void getnx() {
  nxt[0] = 0;
  int j = 0;
  for (int i = 1; i < nc; i++) {
    for (; c[j] != c[i] && j > 0; j = nxt[j - 1])
      ;
    if (c[j] == c[i]) ++j;
    nxt[i] = j;
  }
}
void dfs(data cur) {
  int cx = cur.x, cy = cur.y, cz = cur.z;
  if (cx == cy && cy == cz && cz == 0) return;
  data ch = pre[cx][cy][cz];
  dfs(ch);
  int hx = ch.x, hy = ch.y, hz = ch.z;
  if (dp[hx][hy][hz] + 1 == dp[cx][cy][cz]) printf("%c", a[hx]);
}
int main() {
  scanf("%s", a);
  scanf("%s", b);
  scanf("%s", c);
  memset(dp, 0, sizeof dp);
  na = strlen(a);
  nb = strlen(b);
  nc = strlen(c);
  getnx();
  for (int i = 0; i <= na; i++)
    for (int j = 0; j <= nb; j++) dp[i][j][0] = 0;
  for (int i = 0; i <= na; i++) {
    for (int j = 0; j <= nb; j++) {
      for (int k = 0; k < nc; 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;
          for (; a[i] != c[w] && w > 0; w = nxt[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 mx = 0;
  for (int k = 0; k < nc; k++) {
    if (dp[na][nb][k] > mx) {
      mx = dp[na][nb][k];
      e.x = na;
      e.y = nb;
      e.z = k;
    }
  }
  if (mx == 0) return puts("0"), 0;
  dfs(e);
  return 0;
}