#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using pll = pair<ll, ll>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
int main() {
  cin.sync_with_stdio(0);
  string a, b;
  cin >> a >> b;
  a = "a" + a;
  b = "a" + b;
  vl subind(ll((b).size()));
  ll pos = ll((a).size()) - 1;
  for (ll i = ll(ll((b).size())) - 1; i >= (0); i--) {
    while (pos >= 0 && a[pos] != b[i]) pos--;
    subind[i] = pos;
    pos--;
  }
  ll max_res = 0, start = -1, end = -1;
  ll apos = 0;
  for (ll startpos = (0); startpos < (ll((b).size())); startpos++) {
    while (apos < ll((a).size()) && a[apos] != b[startpos]) apos++;
    if (apos >= ll((a).size())) break;
    auto it = upper_bound(subind.begin() + startpos, subind.end(), apos);
    ll res;
    if (it == subind.end()) {
      res = startpos + 1;
    } else {
      res = startpos + 1 + distance(it, subind.end());
    }
    if (res > max_res) {
      max_res = res;
      start = startpos + 1;
      end = distance(subind.begin(), it) - 1;
    }
    apos++;
  }
  if (max_res <= 1) {
    cout << "-";
  } else {
    for (ll i = (1); i < (start); i++) {
      cout << b[i];
    }
    for (ll i = (max(end + 1, start)); i < (ll((b).size())); i++) {
      cout << b[i];
    }
  }
  cout << endl;
}
