#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string a, b;
  cin >> a >> b;
  vector<int> pref, suf;
  int pos = 0;
  for (int i = 0; i < a.size() && pos < b.size(); ++i)
    if (a[i] == b[pos]) {
      pref.push_back(i);
      ++pos;
    }
  pos = b.size() - 1;
  for (int i = a.size() - 1; i >= 0 && pos >= 0; --i)
    if (a[i] == b[pos]) {
      suf.push_back(i);
      --pos;
    }
  if (pref.size() + suf.size() == 0)
    cout << "-" << endl;
  else if (pref.size() != 0) {
    int pbegin = pref.size() - 1, pend = -1;
    int pos = pbegin, ptr = 0;
    while (pos >= 0) {
      while (ptr < suf.size() && (pos + ptr + 2 < b.size()) &&
             pref[pos] < suf[ptr])
        ++ptr;
      if (pbegin + pend < pos + ptr - 1) {
        pbegin = pos;
        pend = ptr - 1;
      }
      --pos;
    }
    if (suf.size() > pbegin + pend + 2) {
      pbegin = -1;
      pend = suf.size() - 1;
    }
    for (int i = 0; i <= pbegin; ++i) cout << a[pref[i]];
    for (int i = pend; i >= 0; --i) cout << a[suf[i]];
    cout << endl;
  } else {
    for (int i = suf.size() - 1; i >= 0; --i) cout << a[suf[i]];
    cout << endl;
  }
  return 0;
}
