#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  char *a = new char[100002];
  char *b = new char[100002];
  scanf("%s", a);
  scanf("%s", b);
  int lena = strlen(a);
  int lenb = strlen(b);
  vector<int> pref(lenb + 1);
  vector<int> suff(lenb + 1);
  int j = 0;
  int i;
  for (i = 0; i < lenb; ++i) {
    while (j < lena && b[i] != a[j]) ++j;
    pref[i + 1] = j + 1;
    ++j;
  }
  j = lena - 1;
  for (i = lenb - 1; i >= 0; --i) {
    while (j >= 0 && b[i] != a[j]) --j;
    suff[lenb - i] = lena - j;
    --j;
  }
  j = lenb - 1;
  int max = 0;
  int ii, jj;
  for (i = 0; i <= lenb; i++) {
    while (pref[i] + suff[j] > lena && j >= 0) j--;
    if (j < 0) break;
    if (pref[i] + suff[j] <= lena && i + j > max && i + j <= lenb) {
      ii = i;
      jj = j;
      max = i + j;
    }
  }
  if (max == 0) {
    putchar('-');
  } else {
    for (i = 0; i < ii; i++) putchar(b[i]);
    for (i = lenb - jj; i < lenb; i++) putchar(b[i]);
  }
  return 0;
}
