#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
string a, b, revA, revB;
vector<int> all[300], revAll[300];
int bestR[N], bestL[N];
int main() {
  memset(bestR, -1, sizeof bestR);
  memset(bestL, -1, sizeof bestL);
  cin >> a >> b;
  for (int i = 0; i < a.size(); ++i) {
    all[a[i]].push_back(i);
  }
  int idx = -1, matched = 0;
  while (matched < b.size() && idx < (int)a.size()) {
    vector<int>::iterator it =
        upper_bound(all[b[matched]].begin(), all[b[matched]].end(), idx);
    int nxt = -1;
    if (it == all[b[matched]].end()) break;
    nxt = *(it);
    bestR[matched] = nxt;
    idx = nxt;
    matched++;
  }
  revA = a;
  revB = b;
  reverse(revA.begin(), revA.end());
  reverse(revB.begin(), revB.end());
  for (int i = 0; i < revA.size(); ++i) {
    revAll[revA[i]].push_back(i);
  }
  idx = -1, matched = 0;
  while (matched < revB.size() && idx < (int)revA.size()) {
    vector<int>::iterator it = upper_bound(revAll[revB[matched]].begin(),
                                           revAll[revB[matched]].end(), idx);
    int nxt = -1;
    if (it == revAll[revB[matched]].end()) break;
    nxt = *(it);
    bestL[revB.size() - 1 - matched] = revA.size() - 1 - nxt;
    idx = nxt;
    matched++;
  }
  int fn1 = -1, fn2 = -1;
  int mn = b.size();
  for (int i = 0; i < b.size(); ++i) {
    if (bestR[i] == -1) continue;
    int lo = i + 1, hi = b.size(), bestK = b.size();
    while (lo <= hi) {
      int mid = (lo + hi) / 2;
      if (bestL[mid] > bestR[i]) {
        bestK = min(bestK, mid);
        hi = mid - 1;
      } else {
        lo = mid + 1;
      }
    }
    if (bestK - i - 1 < mn) {
      mn = bestK - i - 1;
      fn1 = i;
      fn2 = bestK;
    }
  }
  for (int i = 0; i < b.size(); ++i) {
    if (bestL[i] == -1) continue;
    if (i < mn) {
      mn = i;
      fn1 = -1;
      fn2 = i;
    }
  }
  if (mn == b.size())
    puts("-");
  else {
    for (int i = 0; i <= fn1; ++i) {
      printf("%c", b[i]);
    }
    for (int i = fn2; i < b.size(); ++i) {
      printf("%c", b[i]);
    }
    puts("");
  }
  return 0;
}
