import Foundation
let inp = readLine()!.split(separator: " ").map { Int($0)! }

let n = inp[0]
let k = inp[1]

if k > (n-1) * (n-2) / 2 {
  print("-1")
  exit(0)
}

var m = n - 1

var graph: [[Int]] = .init(repeating: [], count: n+1)
graph[1] = Array((2...n).map { $0 } )
for i in 2...n {
  graph[i].append(1)
}

var c = (n-1) * (n-2) / 2

for i in 2..<n {
  for j in i+1...n {
    if c == k {
      break
    }
    graph[i].append(j)
    c -= 1
    m += 1
  }
}

print(m)
for i in 1...n {
  for nei in graph[i] {
    print(i, nei)
  }
}