{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Char
import Data.Int
import Data.Foldable
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int -> [(Int, Int)]
solve !n !k | k > n1C2  = []
            | otherwise = scatterTo1 ++ drop k edges
 where
  n1C2       = (n - 1) * (n - 2) `div` 2
  edges      = [ (x, y) | x <- [2 .. n - 1], y <- [x + 1 .. n] ]
  scatterTo1 = [ (1, n) | n <- [2 .. n] ]

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (n, k) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  let xs = solve n k

  if null xs
    then print (-1)
    else do
      print $ length xs
      forM_ xs $ \(x, y) -> putStrLn $ show x ++ " " ++ show y
