N, K = gets.chomp.split(" ").map(&:to_i)

ans = []
if K <= ((N-1)*(N-2))/2 then
  (1...N).each{|n| ans << [n, N]}
  wk = ((N-1)*(N-2))/2
  (1..(N-2)).each{|i|
    ((i+1)..(N-1)).each{|j|
      break if wk == K
      ans << [i, j]
      wk -= 1
    }
    break if wk == K
  }
end

if ans.size == 0 then
  puts -1
else
  puts ans.size
  puts ans.map{|a| a*?\s}*?\n
end
