#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
inline void chmin(A &a, B b) {
  if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b) {
  if (a < b) a = b;
}
void calc(string &S, string &T, vector<long long> &v, string &s) {
  v.resize(T.size() + 1);
  v[0] = 0;
  long long cur = 0;
  for (long long i = 0; i < (T.size()); i++) {
    while (cur < S.size() && S[cur] != T[i]) cur++;
    v[i + 1] = cur + 1;
    if (cur < S.size()) s += S[cur];
    cur++;
  }
}
signed main() {
  string S, T;
  cin >> S >> T;
  vector<long long> pre, suf;
  string s, t;
  calc(S, T, pre, s);
  reverse((S).begin(), (S).end());
  reverse((T).begin(), (T).end());
  calc(S, T, suf, t);
  reverse((t).begin(), (t).end());
  long long cur = suf.size() - 1;
  long long ans = LLONG_MIN, mav = -1;
  for (long long i = 0; i < pre.size(); i++) {
    while (cur >= 0 && (pre[i] + suf[cur] > S.size() || i + cur > T.size()))
      cur--;
    if (cur == -1) break;
    if (ans < i + cur) {
      mav = i;
      ans = i + cur;
    }
  }
  if (ans == 0)
    cout << "-" << endl;
  else
    cout << s.substr(0, mav) << t.substr(t.size() - (ans - mav), ans - mav)
         << endl;
  return 0;
}
