n,k = gets.chomp.split(" ").map(&:to_i)

m = n*(n-1)/2 -k

if m >= n-1
    puts m
    cnt = 1
    for i in 1..n-1 do
        for j in i+1..n do
            print i," ",j,"\n"
            cnt += 1
            if cnt > m
                break
            end
        end
        if cnt > m
            break
        end
    end
else
    puts "-1"
end