N, K = gets.split.map(&:to_i)
if K>(N-1)*(N-2)/2
  puts "-1"
  exit(0)
end
ans=[]
(2..N).each do |i|
  ans << [1, i]
end
cnt=0
from=2
to = 3
while cnt < (N-1)*(N-2)/2 - K
  if to > N
    to = from + 1
    from += 1
  end
  ans << [from, to]
  to += 1
  cnt += 1
end
puts ans.size
ans.each do |e|
  puts "#{e[0]} #{e[1]}"
end