#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  if (!b) return a;
  return gcd(b, a % b);
}
template <class T>
T power(T a, T b) {
  T res(1);
  while (b) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
template <class T>
T powerM(T a, T b, T mod) {
  T res(1);
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
const int infi = 2147483647;
const long long infl = 9223372036854775807;
int n, m;
string a, b;
int h[1101000], x, y, ans;
int T[1101000];
int main() {
  getline(cin, a), getline(cin, b);
  n = a.length(), m = b.length();
  int i = 0, j = 0;
  memset(h, -1, sizeof h), memset(T, -1, sizeof T);
  while (1) {
    if (j == m) {
      x = j - 1;
      ans = j;
      break;
    }
    while (a[i] != b[j] && i < n) i++;
    if (i < n) {
      h[j] = i;
      j++;
      i++;
    } else {
      x = j - 1;
      ans = j;
      break;
    }
  }
  i = n - 1, j = m - 1;
  while (1) {
    if (j == -1) {
      y = j + 1;
      ans = max(ans, m - j - 1);
      break;
    }
    while (a[i] != b[j] && i >= 0) i--;
    if (i >= 0) {
      T[j] = i;
      j--;
      i--;
    } else {
      y = j + 1;
      ans = max(ans, m - j - 1);
      break;
    }
  }
  if (ans == m) {
    cout << b;
    return 0;
  }
  if (x == -1 && y == m) {
    puts("-");
    return 0;
  } else {
    if (x == -1) {
      cout << b.substr(m - ans);
      return 0;
    } else {
      if (y == m) {
        cout << b.substr(0, ans);
        return 0;
      } else {
        int i = 0, j = y;
        int l(-1), r(-1);
        while (i <= x && j < m) {
          while (h[i] >= T[j] && j < m) j++;
          if (j == m) break;
          if (i + 1 + m - j > ans) {
            ans = i + 1 + m - j;
            l = i, r = j;
          }
          i++;
        }
        if (r > -1) {
          cout << b.substr(0, l + 1) + b.substr(r);
        } else {
          if (ans == x + 1)
            cout << b.substr(0, ans);
          else
            cout << b.substr(m - ans);
        }
      }
    }
  }
  return 0;
}
