
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)

main :: IO ()
main = do
    [n,k] <- r'
    case solve n k of
            Nothing -> print (-1)
            Just ls -> do
                print $ length ls
                mapM_ printTup ls

printTup (a,b) = putStrLn (show a ++" "++show b)

solve :: Int -> Int -> Maybe [(Int,Int)]
solve n k
    | k <  n-2 = Nothing
    | k == n-2 = Just [(i,i+1) | i<-[1..(n-1)]]
    | k > n-2  = let rest = k-(n-1)
            in if rest*3+1 > n then Nothing
                else Just $ [(i,i+1) | i<-[1..(n-1)]]++[(i-2,i) | i<-[4,7..(n-1)]]

