#include <bits/stdc++.h>
using namespace std;
int INF = 1e9;
int main() {
  string a, b;
  cin >> a >> b;
  int sa = a.size();
  int sb = b.size();
  vector<int> pre(sb + 1, INF);
  vector<int> suf(sb + 1, INF);
  pre[0] = 0;
  suf[0] = 0;
  for (int i = 1, cur = 0; i <= sb; i++)
    for (cur; cur < sa; cur++)
      if (b[i - 1] == a[cur]) {
        pre[i] = cur + 1;
        cur++;
        break;
      }
  for (int i = 1, cur = 0; i <= sb; i++)
    for (cur; cur < sa; cur++)
      if (b[sb - i] == a[sa - 1 - cur]) {
        suf[i] = cur + 1;
        cur++;
        break;
      }
  vector<int> pval(sa + 1), sval(sa + 1);
  for (int i = 0; i <= sb && pre[i] <= sa; i++) pval[pre[i]] = i;
  for (int i = 1; i <= sa; i++)
    if (pval[i] == 0) pval[i] = pval[i - 1];
  for (int i = 0; i <= sb && suf[i] <= sa; i++) sval[suf[i]] = i;
  for (int i = 1; i <= sa; i++)
    if (sval[i] == 0) sval[i] = sval[i - 1];
  int mx = 0, maxid = 0;
  for (int i = 0; i <= sa; i++) {
    int cur = pval[i] + sval[sa - i];
    if (cur > mx) mx = cur, maxid = i;
  }
  if (mx >= sb) {
    cout << b;
    return 0;
  }
  for (int i = 0; i < pval[maxid]; i++) cout << b[i];
  for (int i = sb - sval[sa - maxid]; i < sb; i++) cout << b[i];
  if (mx == 0) cout << "-";
}
