N,_=gets.chomp.split(' ').map{|n| n.to_i}

arr = []
if(N%2==1)
	for i in 1..(N-1)
		for j in (i+1)..(N)
			arr << "#{i} #{j}" if j!=i && j!=(N-i)
		end
	end
else
	for i in 1..(N-1)
		for j in (i+1)..(N)
			arr << "#{i} #{j}" if j!=i && j!=(N+1-i)
		end
	end
end
puts arr.size
puts arr
