#include <bits/stdc++.h>
using namespace std;
string a, b;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> a >> b;
  int lst = 0;
  string l = "", r = "";
  vector<int> pos[2];
  for (int i = 0; i < b.length(); ++i) {
    while (lst < a.length() && a[lst] != b[i]) ++lst;
    if (a[lst] == b[i]) {
      l += b[i];
      pos[0].push_back(lst);
      ++lst;
    } else
      break;
  }
  lst = a.length() - 1;
  for (int i = b.length() - 1; i >= 0; --i) {
    while (lst >= 0 && a[lst] != b[i]) --lst;
    if (a[lst] == b[i]) {
      r += b[i];
      pos[1].push_back(lst);
      --lst;
    } else
      break;
  }
  reverse(pos[1].begin(), pos[1].end());
  reverse(r.begin(), r.end());
  string res = "";
  int szl = 0, szr = 0, posl = -1, posr = -1;
  for (int i = 0; i < pos[0].size(); ++i) {
    int up =
        upper_bound(pos[1].begin(), pos[1].end(), pos[0][i]) - pos[1].begin();
    if (up != (int)pos[1].size()) {
      if (szl + szr < i + 1 + pos[1].size() - up) {
        szl = i + 1;
        szr = pos[1].size() - up;
        posl = i;
        posr = up;
      }
    }
  }
  if (posl != -1 && posr != -1) {
    res = l.substr(0, posl + 1) + r.substr(posr);
  }
  if (res.length() < l.length()) res = l;
  if (res.length() < r.length()) {
    res = r;
  }
  if (res.length() > b.length()) res = b;
  if (res.length() == 0) res = "-";
  cout << res << endl;
  return 0;
}
