N,K = gets.split.map(&:to_i)
e = (N-1)*(N-2)/2
if K > e
  p -1
  exit
end
ans = []
(N-1).times do |i|
  ans << [i+1,N]
end
a,b = 1,2
while e != K
  ans << [a,b]
  if b == N-1
    a += 1
    b = a + 1
  else
    b += 1
  end
  e -= 1
end
p ans.length
ans.each do |t|
  puts t.join(" ")
end