#include <bits/stdc++.h>
using namespace std;
vector<int> solve(string a, string b) {
  vector<int> ans(b.size() + 1, a.size() + 1);
  ans[0] = 0;
  int l = 0;
  for (int i = 0; i < b.size(); ++i) {
    while (l < a.size() && a[l] != b[i]) ++l;
    if (l == a.size()) return ans;
    ans[i + 1] = l + 1;
    ++l;
  }
  return ans;
}
int main() {
  string a, b;
  cin >> a >> b;
  vector<int> n1 = solve(a, b);
  vector<int> n2 =
      solve(string(a.rbegin(), a.rend()), string(b.rbegin(), b.rend()));
  int r = b.size();
  int ans = 0, take_l, take_r;
  for (int i = 0; i <= b.size(); ++i) {
    while (r + i > b.size() || r > 0 && n1[i] + n2[r] > a.size()) --r;
    if (n1[i] + n2[r] <= a.size()) {
      if (i + r > ans) {
        ans = i + r;
        take_l = i;
        take_r = r;
      }
    }
  }
  if (ans == 0)
    puts("-");
  else
    cout << string(b.begin(), b.begin() + take_l) +
                string(b.end() - take_r, b.end())
         << '\n';
}
