-- 139 f 

import Control.Monad
import Data.List

main :: IO()
main = do

    [n, k] <- (map (read :: String -> Int) . words) <$> getLine
    
    let maxk = (n - 1) * (n -2) `div` 2

    if maxk < k
    then 
        print (-1)
    else
        
        let arr1 = do
            i <- [2..n]
            return (1,i) in

        let arr2 = do
            i <- [2..n]
            j <- [(i+1)..n ]
            return (i,j) in
        
        let arr3 = arr1 ++ (drop k arr2) in

        let m = length arr3 in

        let printfunc d = putStrLn str
                where 
                    (i,j) = d 
                    str = (show i ) ++ " " ++ (show j) in
                        
        (print m) >> (forM_ arr3 printfunc)


