#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, pat;
  cin >> pat >> s;
  vector<long long> l, r;
  l.push_back(-1);
  r.push_back(pat.size());
  for (long long i = 0; i < pat.size() && l.size() <= s.size(); i++) {
    if (s[l.size() - 1] == pat[i]) {
      l.push_back(i);
    }
  }
  for (long long i = pat.size() - 1; i >= 0 && r.size() <= s.size(); i--) {
    if (s[s.size() - r.size()] == pat[i]) {
      r.push_back(i);
    }
  }
  long long len = 0, lt = 0, rt = s.size() - 1;
  for (long long i = 0, j = r.size() - 1; i < l.size() && j >= 0;) {
    if (l[i] >= r[j]) {
      j--;
    } else {
      if (len < (i + j)) {
        len = i + j;
        lt = i;
        rt = s.size() - j - 1;
      }
      i++;
    }
  }
  if (lt > rt) {
    lt = rt + 1;
  }
  if (len == 0) {
    cout << "-";
  } else {
    for (long long i = 0; i < lt; i++) cout << s[i];
    for (long long i = rt + 1; i < s.size(); i++) cout << s[i];
  }
  return 0;
}
