fun main(args: Array<String>) {
    val (N, K) = listOfInt()
    val M = (N - 1) * (N - 2) / 2
    if (K > M) {
        println(-1)
        return
    }
    val ans = mutableListOf<Pair<Int, Int>>()
    repeat(N-1) { ans.add(Pair(it + 1, N)) }
    val L = M - K
    var edge = mutableListOf<Pair<Int, Int>>()
    for (n in 0 until N - 1) for (m in 0 until n) edge.add(Pair(n + 1, m + 1))
    repeat(L) { ans.add(edge[it]) }
    println("${ans.count()}")
    ans.forEach { println("${it.first} ${it.second}") }
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
