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

max = (n-1)*(n-2)/2
if max < k
  puts(-1)
else
  puts((n-1) + (max - k))
  (2..n).each do |i|
    puts("1 #{i}")
  end
  count = 0
  (2..(n-1)).each do |i|
    break if count >= max - k
    ((i+1)..n).each do |j|
      break if count >= max - k
      puts("#{i} #{j}")
      count += 1
    end
  end
end