#include <bits/stdc++.h>
using namespace std;
int f[200000], t[200000];
int nx[26][200000], ny[26][200000];
int main() {
  string a, b;
  cin >> a >> b;
  for (int i = 0; i < (26); i++) {
    nx[i][a.size()] = a.size();
    for (int j = a.size() - 1; j >= 0; j--) {
      if (a[j] - 'a' == i)
        nx[i][j] = j;
      else
        nx[i][j] = nx[i][j + 1];
    }
  }
  for (int i = 0; i < (26); i++) {
    for (int j = 0; j < a.size(); j++) {
      if (a[j] - 'a' == i)
        ny[i][j] = j;
      else
        ny[i][j] = (j ? ny[i][j - 1] : -1);
    }
  }
  for (int i = 0; i < (b.size()); i++) {
    if (i == 0)
      f[i] = nx[b[i] - 'a'][0];
    else
      f[i] =
          (f[i - 1] >= a.size() - 1 ? a.size() : nx[b[i] - 'a'][f[i - 1] + 1]);
  }
  for (int i = b.size() - 1; i >= 0; i--) {
    if (i == b.size() - 1)
      t[i] = ny[b[i] - 'a'][a.size() - 1];
    else
      t[i] = (t[i + 1] <= 0 ? -1 : ny[b[i] - 'a'][t[i + 1] - 1]);
  }
  t[b.size()] = a.size();
  int l = 0, r = INT_MAX;
  for (int R = 0; R < (b.size() + 1); R++) {
    if (t[R] == -1) continue;
    int L = lower_bound(f, f + R, t[R]) - f;
    if (r - l > R - L) l = L, r = R;
  }
  for (int i = 0; i < l; i++) cout << b[i];
  for (int i = r; i < b.size(); i++) cout << b[i];
  if (r - l >= b.size()) cout << "-";
  cout << endl;
}
