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>
const int N = 1e2 + 10;
const int inf = 0x3f3f3f3f;
const double eps = 1e-7;
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
using namespace std;
struct node {
  int x, y, z;
} pre[N][N][N];
int dp[N][N][N], ne[N];
string a, b, c;
void print(node t) {
  int x = t.x, y = t.y, z = t.z;
  if (x == 0 && y == 0 && z == 0) return;
  node q = pre[x][y][z];
  print(q);
  if (dp[q.x][q.y][q.z] + 1 == dp[x][y][z]) printf("%c", a[q.x]);
}
int main() {
  cin >> a >> b >> c;
  int lb = c.size();
  for (int i = 0, j = -1; i <= lb; i++, j++) {
    ne[i] = j;
    while (~j && c[i] != c[j]) j = ne[j];
  }
  int n = a.size(), m = b.size(), q = c.size();
  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 && a[i] != c[w]) w = ne[w];
          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;
  node e;
  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)
    puts("0");
  else
    print(e);
  return 0;
}