#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 15;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string a, b;
  cin >> a >> b;
  int preffix[MAXN];
  int suffix[MAXN];
  memset(preffix, -1, sizeof(preffix));
  memset(suffix, -1, sizeof(suffix));
  int curr = 0;
  for (int i = 0; i < b.size(); i++) {
    while (curr < a.size() && b[i] != a[curr]) curr++;
    if (curr < a.size()) {
      preffix[i] = curr + 1;
      curr++;
    } else
      break;
  }
  curr = a.size() - 1;
  for (int i = b.size() - 1; i >= 0; i--) {
    while (curr >= 0 && b[i] != a[curr]) curr--;
    if (curr >= 0) {
      suffix[i] = a.size() - curr;
      curr--;
    } else
      break;
  }
  pair<int, int> ans = make_pair(-1, -1);
  int max_length = -1;
  for (int i = 0; i < b.size(); i++) {
    int left = i;
    int right = b.size() - 1;
    if (preffix[i] == -1) break;
    if (i + 1 > max_length) {
      max_length = i + 1;
      ans.first = i + 1;
      ans.second = b.size() - 1;
    }
    while (left <= right) {
      int mid = (left + right) / 2;
      if (suffix[mid] == -1 || (preffix[i] + suffix[mid] > a.size())) {
        left = mid + 1;
      } else {
        if (((i + 1) + (b.size() - mid)) > max_length) {
          max_length = (i + 1) + (b.size() - mid);
          ans.first = i + 1;
          ans.second = mid - 1;
        }
        right = mid - 1;
      }
    }
  }
  for (int i = b.size() - 1; i >= 0; i--) {
    if (suffix[i] == -1) break;
    int wawa = b.size() - i;
    if (wawa > max_length) {
      ans.first = 0;
      ans.second = i - 1;
      max_length = b.size() - i;
    }
  }
  if (max_length == -1) {
    cout << "-";
  } else {
    for (int i = 0; i < b.size(); i++) {
      if (i >= ans.first && i <= ans.second) continue;
      cout << b[i];
    }
  }
}
