
object Main extends App {
  import scala.io.StdIn._
  val Array(n, k) = readLine.trim.split(' ').map(_.toInt)
  if ((n - 1) * (n - 2) / 2 < k) {
    println("-1")
  }else {
    var rest = (n - 1) * (n - 2) / 2 - k
    println(n - 1 + rest)
    for (i <- 1 until n) {
      println(s"$i $n")
    }
    for (i <- 1 until n; j <- 1 until i) {
      if (rest > 0) {
        println(s"$i $j")
        rest -= 1
      }
    }
  }
}
