#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string a, b;
  cin >> a >> b;
  int n = a.size(), m = b.size();
  vector<int> prefix(m + 2), surfix(m + 2);
  for (int i = 0, j = 0; i < m; ++i) {
    for (; j < n && a[j] != b[i]; ++j)
      ;
    prefix[i + 1] = j++;
  }
  prefix[0] = -1;
  for (int i = m - 1, j = n - 1; i >= 0; --i) {
    for (; j >= 0 && a[j] != b[i]; --j)
      ;
    surfix[i + 1] = j--;
  }
  surfix[m + 1] = n;
  int ans = m, head = -1, tail = m;
  for (int i = 0, j = 1; i <= m; ++i) {
    if (prefix[i] >= n) break;
    for (j = max(j, i + 1); j <= m + 1 && prefix[i] >= surfix[j]; ++j)
      ;
    if (ans > j - i - 1) ans = j - i - 1, head = i - 1, tail = j - 1;
  }
  string s = "";
  s += b.substr(0, head + 1);
  if (tail < m) s += b.substr(tail, m - tail);
  if (!s.size()) s = '-';
  cout << s << '\n';
  return 0;
}
