#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  string ans1, ans2, ans;
  vector<int> an, bn;
  int j = 0;
  int n = a.length();
  for (int i = 0; i < n; i++) {
    if (j == b.size()) break;
    if (a[i] == b[j]) {
      an.push_back(i);
      ans1.push_back(a[i]);
      j++;
    }
  }
  j = b.length() - 1;
  for (int i = n - 1; i + 1; i--) {
    if (j < 0) break;
    if (a[i] == b[j]) {
      bn.push_back(i);
      ans2.push_back(a[i]);
      j--;
    }
  }
  int i = 0;
  j = bn.size() - 1;
  int pi = 0, pj = 0, m = 0;
  while (i < an.size()) {
    while (j >= 0 and bn[j] <= an[i]) j--;
    if (j == -1) break;
    if (i + j + 2 > m) {
      m = i + j + 2;
      pi = i;
      pj = j;
    }
    i++;
  }
  string aa, bb;
  if (m and pi + pj + 2 <= b.size()) {
    aa = ans1.substr(0, pi + 1);
    bb = ans2.substr(0, pj + 1);
    reverse(bb.begin(), bb.end());
    ans = aa + bb;
  }
  reverse(ans2.begin(), ans2.end());
  if (!ans.length() and !ans2.length() and !ans1.length()) {
    cout << '-' << endl;
  } else if (ans1.length() >= ans2.length() and ans1.length() >= ans.length()) {
    cout << ans1 << endl;
  } else if (ans2.length() >= ans1.length() and ans2.length() >= ans.length()) {
    cout << ans2 << endl;
  } else if (ans.length() >= ans1.length() and ans.length() >= ans2.length()) {
    cout << ans << endl;
  }
  return 0;
}
