#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const long long INF = 1e15 + 7;
string a, b;
int suf[N];
int pref[N];
vector<int> v[150];
int get(char x, int cur) {
  int l = 0;
  int r = v[x].size() - 1;
  if (v[x].size() == 0) {
    return -1;
  }
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (v[x][mid] < cur) {
      l = mid;
    } else {
      r = mid;
    }
  }
  if (v[x][l] >= cur)
    return v[x][l];
  else if (v[x][r] >= cur)
    return v[x][r];
  return -1;
}
int get1(char x, int cur) {
  int l = 0;
  int r = v[x].size() - 1;
  if (v[x].size() == 0) {
    return -1;
  }
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (v[x][mid] > cur) {
      r = mid;
    } else {
      l = mid;
    }
  }
  if (v[x][r] <= cur)
    return v[x][r];
  else if (v[x][l] <= cur)
    return v[x][l];
  return -1;
}
int main() {
  cin >> a >> b;
  for (int i = 0; i < a.size(); i++) {
    v[a[i]].push_back(i);
  }
  int cur = 0;
  int r = -1;
  int F = 0;
  int S = -1;
  int mn = int(b.size()) + 1;
  int F1 = int(b.size());
  int S1 = -1;
  for (int i = 0; i < b.size(); i++) {
    int pos = get(b[i], cur);
    if (pos == -1) {
      break;
    }
    mn = int(b.size()) - (i + 1);
    F = 0;
    S = i;
    cur = pos + 1;
    pref[i] = pos;
    r++;
  }
  cur = (int)a.size() - 1;
  for (int i = b.size() - 1; i >= 0; i--) {
    int pos = get1(b[i], cur);
    if (pos == -1) {
      break;
    }
    if (i < mn) {
      mn = i;
      F = 0;
      S = -1;
      F1 = i;
      S1 = int(b.size()) - 1;
    }
    int l = 0;
    int hi = min(r, i - 1);
    while (hi - l > 1) {
      int mid = (l + hi) / 2;
      if (pref[mid] < pos)
        l = mid;
      else
        hi = mid;
    }
    if (pref[hi] < pos) {
      if (mn > int(b.size()) - (hi + 1 + (int(b.size()) - i))) {
        mn = int(b.size()) - (hi + 1 + (int(b.size()) - i));
        F1 = i;
        S1 = int(b.size() - 1);
        F = 0;
        S = hi;
      }
    } else if (pref[l] < pos) {
      if (mn > int(b.size()) - (l + 1 + (int(b.size()) - i))) {
        mn = int(b.size()) - (l + 1 + (int(b.size()) - i));
        F1 = i;
        S1 = int(b.size() - 1);
        F = 0;
        S = l;
      }
    }
    cur = pos - 1;
  }
  string ans;
  for (int i = F; i <= S; i++) {
    ans += b[i];
  }
  for (int i = F1; i <= S1; i++) {
    ans += b[i];
  }
  if (ans.size() == 0)
    cout << '-';
  else
    cout << ans;
  return 0;
}
