import java.lang.Long.parseLong
import java.util.*

fun main(args:Array<String>) {
    val reader = System.`in`.bufferedReader()
    val (N, K) = reader.readLine()!!.split(" ").map(String::toInt)
//    val S = reader.readLine()!!.split(" ").map(String::toInt).toIntArray()
//    val T = reader.readLine()!!.split(" ").map(String::toInt).toIntArray()
//    val mod = 1000000007
//    var ans = 1L

    var C = (N-1)*(N-2)/2

    if (K > C) {
        println(-1)
        return
    }
    var ans = mutableListOf<String>()

    for (n in 2 .. N) {
        ans.add("1 $n")
    }
    var k = 0
    for (i in 2 until N) {
        for (j in i+1..N) {
            if (C - K == k) break
            k++
            ans.add("$i $j")
        }
    }
    println(N-1+k)
    println(ans.joinToString("\n"))
}