import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Text.Printf

main :: IO ()
main = readLine >>= check 

check :: [Int] -> IO ()
check [n, k] 
    | k > an = print (-1)
    | otherwise = print (n - 1 + an - k) >> printBase >> printOthers 
    where
        an = ((n - 2) * (n - 1)) `div` 2

        printBase = mapM_ (pf . (: [1])) [2..n]
        printOthers = mapM_ pf $ take (an - k) [[i, j] | i <- [2..n], j <- [(i + 1)..n]]

pf :: [Int] -> IO ()
pf [u, v] = printf "%d %d\n" u v

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine