# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

nn = inputs[0][0]
kk = inputs[0][1]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p nn
  p kk
end

max = (nn-1)*(nn-2)/2
if kk > max
  puts "-1"
  exit
end

arr = []
(nn-1).times do |i|
  arr << "1 #{i+2}"
end

#cur = nn - 2
cur = 2
itr = cur + 1
res = max - kk
pd max
pd "res=#{res}"
while res > 0
  arr << "#{cur} #{itr}"
  res -= 1
  if(itr == nn)
    cur += 1
    itr = cur + 1
  else
    itr += 1
  end
end

puts arr.size
arr.each do |a_i|
  puts a_i
end
