#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  string s, t;
  cin >> s;
  cin >> t;
  swap(s, t);
  n = s.size();
  m = t.size();
  int dp1[m];
  if (s[0] == t[0])
    dp1[0] = 1;
  else
    dp1[0] = 0;
  for (int i = 1; i < m; i++)
    if (dp1[i - 1] < n) {
      dp1[i] = dp1[i - 1];
      if (s[dp1[i - 1]] == t[i]) dp1[i]++;
    } else
      dp1[i] = dp1[i - 1];
  int dp2[m + 1];
  reverse(s.begin(), s.end());
  reverse(t.begin(), t.end());
  if (s[0] == t[0])
    dp2[0] = 1;
  else
    dp2[0] = 0;
  for (int i = 1; i < m; i++)
    if (dp2[i - 1] < n) {
      dp2[i] = dp2[i - 1];
      if (s[dp2[i - 1]] == t[i]) dp2[i]++;
    } else
      dp2[i] = dp2[i - 1];
  int mx = 0, p = 0, ll = 0, rr = 0;
  for (int i = -1; i < m; i++) {
    int x = mx;
    int l, r;
    if (i < 0) {
      l = 0;
      r = dp2[m - 1];
      mx = max(mx, dp2[m - 1]);
    } else if (m - i - 2 < 0) {
      l = dp1[i];
      r = 0;
      mx = max(mx, dp1[i]);
    } else {
      mx = max(mx, dp1[i] + dp2[m - i - 2]);
      l = dp1[i];
      r = dp2[m - i - 2];
    }
    if (mx > x) {
      ll = l;
      rr = r;
      p = i;
    }
  }
  string ans = "";
  reverse(s.begin(), s.end());
  for (int i = 0; i < ll; i++) ans += s[i];
  reverse(s.begin(), s.end());
  for (int i = rr - 1; i >= 0; i--) ans += s[i];
  reverse(s.begin(), s.end());
  if (s.size() < ans.size()) ans = s;
  if (ans.size() == 0) ans = '-';
  cout << ans << "\n";
}
