#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n, k;
  cin >> n >> k;
  if ((n - 1) * (n - 2) / 2 < k) {
    cout << -1 << endl;
    return 0;
  }
  int64_t x = (n - 1) * (n - 2) / 2 - k;
  vector<pair<int64_t, int64_t>> vs;
  for (int64_t i = 2; i <= n; i++) {
    vs.push_back({1, i});
  }
  for (int64_t t = 0, i = 2; t < x && i <= n; i++) {
    for (int64_t j = i + 1; j <= n && t < x; j++, t++) {
      vs.push_back({i, j});
    }
  }
  cout << vs.size() << endl;
  for (auto &p : vs) {
    cout << p.first << ' ' << p.second << endl;
  }
  return 0;
}
