n,k = gets.split.map(&:to_i)
if k < n-2 || (n-1)*(n-2)/2 < k
    puts "-1"
    exit
end
sum = (n-1)*(n-2)/2
m = n-1
while (1)
# 10.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
s = ans.size
puts s
s.times do |i|
    puts ans[i].join(" ")
end
