require 'set'; require 'prime'
INF=Float::INFINITY
n,k = gets.chomp.split.map(&:to_i)

kmax = (n-1) * (n-2) / 2
if kmax < k
  puts -1
  exit
end

if n==2
  puts 0
  exit
end

ans = []
2.upto(n).each do |i|
  ans.push [1, i]
end

nokori = kmax - k
2.upto(n-1).each do |i|
  (i+1).upto(n).each do |j|
    break if nokori <= 0
    ans.push [i,j]
    nokori -= 1
  end
end

puts ans.size
ans.each do |line|
  puts line.join(' ')
end