local n, k = io.read("*n", "*n")
local rem = (n - 2) * (n - 1) // 2 - k
if rem < 0 then print(-1) os.exit() end
print(n - 1 + rem)
for i = 1, n - 1 do
  print(i .. " " .. n)
end
if 0 < rem then
  for i = 1, n - 2 do
    for j = i + 1, n - 1 do
      print(i .. " " .. j)
      rem = rem - 1
      if rem == 0 then os.exit() end
    end
  end
end
