n = gets.split.map(&:to_i)
if n[1] == 2
  puts "-1"
  exit
end
friend  = 0
side = []
for i in 2..n[0]
  side.push([1,i])
end
(n[0]-2).downto(1){|i| friend += i}
if friend < n[1]
  puts "-1"
  exit
end
count = 1
check = 2
while friend > n[1]
  if check + count <= n[0]
    friend -= 1
    side.push([check,check+count])
    check += 1
  else
    check = 2
    count += 1
  end
  if count > n[0]
    puts "-1"
    exit
  end
end

puts side.length
(side.length).times{|i| puts side[i].join(" ")}
