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;
int l1, l2, l3;
char s1[105], s2[105], s3[105];
int dp[105][105][105];
int failure[105];
void initFail() {
  failure[0] = 0;
  failure[1] = s3[0] == s3[1];
  for (int i = 2; i < l3; i++) {
    failure[i] = 0;
    int j = failure[i - 1];
    while (1) {
      if (s3[j] == s3[i]) {
        failure[i] = j + 1;
        break;
      }
      if (j == 0) break;
      j = failure[j - 1];
    }
  }
}
string s;
int solve(int a, int b, int c) {
  if (c == l3) {
    return -((int)1e9);
  }
  if (a == l1) return 0;
  if (b == l2) return 0;
  int &ret = dp[a][b][c];
  if (ret != -1) return ret;
  ret = 0;
  if (s1[a] == s2[b]) {
    int newC = c;
    while (newC != -1) {
      if (s3[newC] == s1[a]) {
        break;
      }
      if (newC == 0) {
        newC = -1;
        break;
      }
      newC = failure[newC - 1];
    }
    ret = solve(a + 1, b + 1, newC + 1) + 1;
  }
  int leaveA = solve(a + 1, b, c);
  int leaveB = solve(a, b + 1, c);
  if (leaveA > leaveB) {
    ret = max(ret, leaveA);
  } else {
    ret = max(ret, leaveB);
  }
  return ret;
}
void bktrk(int a, int b, int c) {
  if (c == l3) {
    return;
  }
  if (a == l1) {
    return;
  }
  if (b == l2) {
    return;
  }
  int &ret = dp[a][b][c];
  if (s1[a] == s2[b]) {
    int newC = c;
    while (newC != -1) {
      if (s3[newC] == s1[a]) {
        break;
      }
      if (newC == 0) {
        newC = -1;
        break;
      }
      newC = failure[newC - 1];
    }
    if (solve(a + 1, b + 1, newC + 1) + 1 == ret) {
      s += s1[a];
      return bktrk(a + 1, b + 1, newC + 1);
    }
  }
  int leaveA = solve(a + 1, b, c);
  int leaveB = solve(a, b + 1, c);
  if (leaveA == ret) {
    return bktrk(a + 1, b, c);
  }
  return bktrk(a, b + 1, c);
}
int main() {
  s = "";
  memset(dp, -1, sizeof dp);
  scanf("%s %s %s", s1, s2, s3);
  l1 = strlen(s1);
  l2 = strlen(s2);
  l3 = strlen(s3);
  initFail();
  if (solve(0, 0, 0) == 0) {
    cout << 0 << endl;
    return 0;
  }
  bktrk(0, 0, 0);
  cout << s << endl;
  return 0;
}