# A=gets.to_i
# B=gets.split.map(&:to_i)
# C=N.times.map{gets.to_i}
# D=N.times.map{gets.split.map(&:to_i)}
# S=gets.chomp
# MOD=1000000007

N,K=gets.split.map(&:to_i)

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

base=N
out=[]
(N-1).times do |i|
  out << "#{base} #{i+1}"
end

count=(N-1)*(N-2)/2
a,b=base-1,base-2
while count!=K
  out << "#{a} #{b}"
  if b!=1
    b-=1
  else
    a-=1
    b=a-1
  end
  count-=1
end

puts out.size
puts out.join("\n")