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

path = Array.new(n) {|i| [i+1]}
sum = n - 2
i = 2
n.downto(2) do |j|
    #p [i, j, sum, path]
    break if i == j - 1
    if sum + path[i].size <= k
        sum += path[i].size
        path[i] << j
        path[j-1] = []
    else
        i += 1
        redo
    end
end

if sum != k
    puts -1
    exit
end

puts n - 1
1.upto(n-1) do |i|
    path[i].each {|e| puts "#{i} #{e}"}
end