#include <bits/stdc++.h>
using namespace std;
char s[100005], t[100005];
int lens, lent;
int a[100005], b[100005];
int find1(int pos) {
  int ans = -1, l = 1, r = lent + 1, mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if (b[mid] >= pos) {
      ans = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  return ans;
}
int main() {
  scanf("%s", s + 1);
  scanf("%s", t + 1);
  lens = strlen(s + 1);
  lent = strlen(t + 1);
  int poss = 1, post = 1;
  while (poss <= lens && post <= lent) {
    while (poss <= lens && s[poss] != t[post]) ++poss;
    a[post] = poss;
    ++post;
    ++poss;
  }
  for (int i = post; i <= lent; ++i) a[i] = lens + 1;
  poss = lens;
  post = lent;
  while (poss >= 1 && post >= 1) {
    while (poss >= 1 && s[poss] != t[post]) --poss;
    b[post] = poss;
    --post;
    --poss;
  }
  for (int i = post; i >= 1; --i) b[i] = 0;
  a[0] = 0;
  b[lent + 1] = lens + 1;
  int ans, pos1, pos2;
  ans = -1;
  for (int i = 0; i <= lent; ++i) {
    int dq, dqlen;
    if (a[i] == lens + 1) break;
    dq = find1(a[i] + 1);
    dq = max(dq, i + 1);
    dqlen = i + lent - dq + 1;
    if (dqlen > ans) {
      ans = dqlen;
      pos1 = i;
      pos2 = dq;
    }
  }
  if (ans == 0) printf("-");
  for (int i = 1; i <= pos1; ++i) printf("%c", t[i]);
  for (int i = pos2; i <= lent; ++i) printf("%c", t[i]);
  return 0;
}
