n,k=gets.split(" ").map{|i|i.to_i}
max = (n-1)*(n-2)/2

if k > max then
  puts "-1"
else
  puts "#{2*(n-1)-k+1}"
  a = n-1-k
  for i in 1..n-1
    puts "1 #{i+1}"
  end
  a = n-1-k+1
  for i in 2..n-1
    for j in 3..n
      if a > 0
        a -= 1
        puts "#{i} #{j}"
      else
        break
      end
    end
    if a <= 0 then
      break
    end
  end
  end