N,K=gets.split.map(&:to_i)
if ((N-1)*(N-2))/2<K
    puts -1
    exit
end
puts N-1+((N-1)*(N-2))/2 - K
(N-1).times do |i|
    puts [1,i+2].join(" ")
end
cnt = ((N-1)*(N-2))/2 - K
exit if cnt == 0
(2..N).to_a.combination(2) do |a,b|
    cnt -= 1
    puts [a,b].join(" ")
    exit if cnt == 0
end
