#include <bits/stdc++.h>
using namespace std;
string a, b;
int f1[100005], f2[100005], res, p1, p2, k, dp2[100005];
int main() {
  cin >> a >> b;
  int n = a.length();
  int m = b.length();
  a = "#" + a;
  b = "#" + b;
  int p = 1;
  for (int i = 1; i <= m; i++) {
    if (p > n) break;
    while (a[p] != b[i] && p <= n) p++;
    if (p <= n) f1[i] = p;
    p++;
  }
  p = n;
  for (int i = 1; i <= max(m, n); i++) f2[i] = -1;
  for (int i = m; i >= 1; i--) {
    if (p < 1) break;
    while (a[p] != b[i] && p >= 1) p--;
    if (p >= 1) f2[i] = p;
    p--;
  }
  for (int i = 1; i <= m; i++)
    if (res < i && f1[i] > 0) {
      res = i;
      p1 = 1;
      p2 = i;
      k = 1;
    }
  for (int i = 1; i <= max(m, n); i++) dp2[i] = n + 1;
  p = n;
  for (int i = m; i >= 1; i--) {
    if (p < 1) break;
    while (a[p] != b[i] && p >= 1) p--;
    if (p >= 1) dp2[i] = p;
    p--;
  }
  for (int i = 1; i <= m; i++)
    if (res < (m - i + 1) && dp2[i] < n + 1) {
      res = (m - i + 1);
      p1 = i;
      p2 = m;
      k = 1;
    }
  int z = 0;
  int x = 0;
  for (int i = 1; i <= m; i++) {
    z = max(z, i + 1);
    while (x <= n && a[x] != b[i]) x++;
    if (x > n) break;
    x++;
    while (f2[z] < x) z++;
    int ans = i + 1 + m - z;
    if (res < ans) {
      res = ans;
      p1 = i;
      p2 = z;
      k = 2;
    }
  }
  if (k == 1)
    for (int i = p1; i <= p2; i++) cout << b[i];
  else if (k == 2) {
    for (int i = 1; i <= p1; i++) cout << b[i];
    for (int i = p2; i <= m; i++) cout << b[i];
  } else
    cout << "-";
  return 0;
}
