import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

alias Graph = int[][];

int c2(int n) {
  return (n * (n-1)) / 2;
}

void main() {
  auto input = readln.split.to!(int[]);
  int N = input[0], K = input[1];

  Graph G = new int[][N];
  int maxK = ((N-1) * (N-2)) / 2;
  if(K > maxK) {
    writeln(-1);
    return;
  }
  
  G[0] = iota(1, N).array;
  int num = maxK;
  outer: foreach(i; 1..N) {
    foreach(j; (1+i)..N) {
      if(num == K) break outer;
      G[i] ~= j;
      num--;
    }
  }

  auto M = G.map!"a.length".sum;
  M.writeln;
  foreach(i; 0..N) {
    foreach(j; G[i]) {
      writeln(i+1, " ", j+1);
    }
  }
}
