'use strict'

function Main(input) {
  const N = Number(input.split(" ")[0])
  const K = Number(input.split(" ")[1])

  if(N !== K + 2) {
    console.log(-1)
    return
  }

  console.log(N-1)
  for(let i=1; i<=N-1; i++) {
    console.log(i, i+1)
  }

}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim())