n,k = gets.chomp.split.collect{ |item| item.to_i}

mmin = n-1
kmax = (n-1)*(n-2)/2
if k > kmax
  puts -1
else
  addline = kmax - k
  m = mmin + addline
  puts m
  center = 1
  mmin.times do |mi|
    puts "#{center} #{mi+2}"
  end
  u = 2
  v = 3
  addline.times do |addi|
    puts "#{u} #{v}"
    v += 1
    if v > n
      u += 1
      v = u+1
    end
  end
end