N, K = gets.split.map(&:to_i)
mx = (N-1)*(N-2)/2
if mx < K
    puts "-1"
    exit
end

ans = (2..N).map{|i| [1, i]}
(2..N).each do |i|
    (2...i).each do |j|
        if mx > K
            mx -= 1
            ans.push([j, i])
        end
    end
end
puts ans.size
ans.each do |arr|
    puts arr.join(' ')
end