N,K=gets.chomp.split(' ').map{|n| n.to_i}
if(N==2 && K>0)
	puts -1
	exit(0)
elsif(N==2)
	puts "1"
	puts "1 2"
	exit(0)
end
max = (N-1)*(N-2)/2
if(max < K)
	puts -1
	exit(0)
end
M = N-1+(max-K)
puts M
for i in 1..(N-1)
	puts "#{1} #{1+i}"
end
cnt = 0
for i in 2..(N-1)
	for j in (i+1)..(N)
		if(cnt == max-K)
			exit(0)
		end
		puts "#{i} #{j}"
		cnt += 1
	end
end
