n, k = gets.split.map(&:to_i)

combs = (n - 1) * (n - 2) / 2

if combs < k
  puts -1
else
  puts (n - 1) + (combs - k)
  (n - 1).times{|i| puts "1 #{i + 2}"}
  
  count = combs - k
  x, y = 2, 3
  count.times do
    puts "#{x} #{y}"
    if y == n
      x += 1
      y = x + 1
    else
      y += 1
    end
  end
end