require 'pp'
N, K = gets.chomp.split(" ").map(&:to_i)
conn = Array.new(N){Array.new(N, false)}
conn[0][1] = true
conn[1][0] = true

if K > N * (N - 1) / 2 - (N - 1)
    puts -1
    exit
end

for j in 1..N-1
    conn[0][j] = true
end

d1 = (N * (N - 1) / 2 - (N - 1)) - K
for i in 1..N-2
    break if d1 == 0
    for j in i+1..N-1
        break if d1 == 0
        conn[i][j] = true
        d1 -= 1
    end
end

puts conn.flatten.count(true)
for i in 0..N-2
    for j in i+1..N-1
        if conn[i][j]
            puts "#{i+1} #{j+1}"
        end
    end
end