n,k = gets.split.map(&:to_i)

ans = n-1
max = (n-1) * (n-2) / 2

if max < k
	puts "-1"
	exit
end

ans += max - k

puts ans

n.downto(2) do |i|
	puts "1 #{i}"
end

count = n-1
(2...n).each do |x|
	(x...n).each do |y|
		puts "#{x} #{y+1}"
		count += 1
		exit if count == ans
	end
end