local mfl = math.floor
local n, k = io.read("*n", "*n")
k = mfl((n - 1) * (n - 2) / 2) - k
if k < 0 then
  print(-1)
else
  local cur = 0
  print(n - 1 + k)
  for i = 2, n do
    print(1 .. " " .. i)
  end
  if k ~= 0 then
    for i = 2, n - 1 do
      for j = i + 1, n do
        print(i .." " .. j)
        cur = cur + 1
        if cur == k then break end
      end
      if cur == k then break end
    end
  end
end
