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;
string s[3];
int l[3];
int a[101][101][101];
int d[101][101][101];
int e[101][26];
int go(int x, int y, int z) {
  if (a[x][y][z] != -1) return a[x][y][z];
  if (z == l[2]) return -1e9;
  if (x == l[0] || y == l[1]) return 0;
  int &r = a[x][y][z];
  r = 0;
  if (go(x + 1, y, z) > r) {
    r = go(x + 1, y, z);
    d[x][y][z] = 1;
  }
  if (go(x, y + 1, z) > r) {
    r = go(x, y + 1, z);
    d[x][y][z] = 2;
  }
  if (s[0][x] == s[1][y]) {
    int c = e[z][s[0][x] - 'A'];
    if (go(x + 1, y + 1, c) + 1 > r) {
      r = go(x + 1, y + 1, c) + 1;
      d[x][y][z] = 200 + c;
    }
  }
  return r;
}
void go1(int x, int y, int z) {
  if (x == l[0] || y == l[1] || z == l[2] || a[x][y][z] == -1) return;
  if (d[x][y][z] == 1)
    go1(x + 1, y, z);
  else if (d[x][y][z] == 2)
    go1(x, y + 1, z);
  else if (d[x][y][z] >= 200) {
    printf("%c", s[0][x]);
    go1(x + 1, y + 1, d[x][y][z] - 200);
  }
}
int main() {
  for (int i = 0; i < 3; i++) {
    getline(cin, s[i]);
    l[i] = s[i].length();
  }
  for (int i = 0; i < l[2]; i++) {
    for (int j = 0; j < 26; j++) {
      string b = s[2].substr(0, i) + string(1, 'A' + j);
      int c = 0;
      for (int k = 1; k <= b.length(); k++) {
        if (b.substr(b.length() - k, k) == s[2].substr(0, k)) c = k;
      }
      e[i][j] = c;
    }
  }
  memset(a, -1, sizeof(a));
  go(0, 0, 0);
  if (a[0][0][0] == 0) {
    printf("0\n");
    return 0;
  }
  go1(0, 0, 0);
  printf("\n");
  return 0;
}