N, K = gets.split.map(&:to_i)
J = (N - 1) * (N - 2) / 2

if K > J
  puts -1
else
  puts (J - K + N - 1)
  puts (2 .. N).map{|v| "#{1} #{v}" }
  puts (2 .. N).to_a.combination(2).take(J - K).map{|u,v| "#{u} #{v}" }
end