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

max_k = (N - 1) * (N - 2) / 2
if K > max_k
  puts -1
  exit
end

m = N - 1 + max_k - K
puts m
2.upto(N) do |i|
  puts "1 #{i}"
end
ring = (2..N).to_a
rsize = ring.size
(max_k - K).times do |k|
  s, i = k.divmod(rsize)
  j = (i + 1 + s) % rsize
  puts "#{ring[i]} #{ring[j]}"
end
