n,k = gets.split.map(&:to_i)
if (n-1)*(n-2)/2 < k
    puts "-1"
    exit
end
if k < n-2
    ans = []
    (n-k-2).times do |i|
        (n-i-1).times do |j|
            ans << [i+1,i+j+2]
        end
    end
    (k+1).times do |i|
        ans << [n-i,n-i-1]
    end
else
    sum = (n-1)*(n-2)/2
    m = n-1
    # while (1)
    100.times do
        if (sum-(m-2) <= k)
            break
        else
            sum -= m-2
            m -= 1
        end
    end
    ans = []
    m.times do |i|
        ans << [1,i+2]
    end
    ((m+2)..n).each do |i|
        ans << [i-1,i]
    end
    (sum-k).times do |i|
        ans << [2,i+3]
    end
end
s = ans.size
puts s
s.times do |i|
    puts ans[i].join(" ")
end
