fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map(String::toInt)
    if (k > (n - 1) * (n - 2) / 2) {
        println(-1)
    } else {
        val m = n * (n - 1) / 2 - k
        println(m)
        var tmp1 = n
        var tmp2 = 1
        for (i in 0 until m) {
            println("$tmp2 $tmp1")
            tmp2++
            if (tmp1 == tmp2) {
                tmp1--
                tmp2 = 1
            }
        }
    }
}
