#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  string sub(string a, string b) {
    int nb = b.size();
    int na = a.size();
    vector<int> p(nb), s(nb);
    int INF = 10000005;
    int l = 0;
    for (int i = 0; i < nb; ++i) {
      while (l < na && b[i] != a[l]) l++;
      if (l >= na) {
        p[i] = INF;
      } else {
        p[i] = l + 1;
      }
      l++;
    }
    int r = na - 1;
    for (int i = nb - 1; i >= 0; --i) {
      while (r >= 0 && b[i] != a[r]) r--;
      if (r < 0) {
        s[i] = INF;
      } else {
        s[i] = na - r;
      }
      r--;
    }
    int tempAns = 0;
    int ansi = -1, ansj = -1;
    for (int i = 0; i < nb; ++i) {
      if (p[i] != INF) {
        ansi = i;
        tempAns = i + 1;
      }
    }
    for (int j = nb - 1; j >= 0; --j) {
      if (s[j] != INF && nb - j > tempAns) {
        {
          ansj = j;
          ansi = -1;
          tempAns = nb - j;
        }
      }
    }
    for (int i = 0; i < nb; ++i) {
      if (p[i] < INF)
        for (int j = i + 1; j < nb; ++j) {
          if (p[i] + s[j] <= na) {
            if (i + 1 + (nb - j) >= tempAns) {
              ansi = i;
              ansj = j;
              tempAns = i + 1 + (nb - j);
            }
            break;
          }
        }
    }
    string ans;
    if (ansi > -1) {
      ans += b.substr(0, ansi + 1);
    }
    if (ansj > -1) {
      ans += b.substr(ansj, nb - ansj + 1);
    }
    if (ans.size() == 0)
      return "-";
    else
      return ans;
  }

 private:
};
int main() {
  string a, b;
  cin >> a >> b;
  Solution s;
  cout << s.sub(a, b);
}
