#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
char A[maxn], B[maxn];
int lena, lenb;
int L[maxn], R[maxn];
int main() {
  scanf("%s", A + 1);
  scanf("%s", B + 1);
  lena = strlen(A + 1);
  lenb = strlen(B + 1);
  L[0] = 0;
  int ans = 0, x, y;
  for (int i = 1; i <= lenb; ++i) {
    int j = L[i - 1] + 1;
    while (j <= lena && A[j] != B[i]) j++;
    L[i] = j;
    if (L[i] <= lena) {
      ans = i;
      x = i;
      y = lenb + 1;
    }
  }
  R[lenb + 1] = lena + 1;
  for (int i = lenb; i >= 1; --i) {
    int j = R[i + 1] - 1;
    while (j >= 1 && A[j] != B[i]) j--;
    R[i] = j;
    if (R[i] >= 1) {
      if (ans < lenb - i + 1) {
        ans = lenb - i + 1;
        x = 0;
        y = i;
      }
    }
  }
  for (int i = lenb; i >= 1 && R[i] >= 1; --i) {
    int tmp = lower_bound(L + 1, L + lenb + 1, R[i] - 1) - L;
    if (L[tmp] > R[i] - 1) tmp--;
    tmp = min(tmp, i - 1);
    if (ans < lenb - i + 1 + tmp) {
      ans = lenb - i + 1 + tmp;
      x = tmp;
      y = i;
    }
  }
  if (ans == 0)
    printf("-");
  else {
    for (int i = 1; i <= x; ++i) {
      printf("%c", B[i]);
    }
    for (int i = y; i <= lenb; ++i) {
      printf("%c", B[i]);
    }
  }
  return 0;
}
