import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val k = cin.nextInt()
    val max = (n-1)*(n-2)/2
    if (k > max) {
        println(-1)
    } else {
        val diff = max - k
        println(n - 1 + diff)
        for (i in 2..n) {
            println("1 ${i}")
        }
        var l = 2
        var r = 3
        for (i in 1..diff) {
            println("$l $r")
            if (r == n) {
                l += 1
                r = l + 1
            } else {
                r += 1
            }
        }
    }
}