import Data.List
import Control.Monad

getLineN n = replicateM n getLine
toTuple [a,b] = (b,a)

type Node = Int
type Edge = (Node, Node)
type Path = [Node]
type Graph = [Edge]

main = do
    [n,k] <- map read.words <$> getLine
    myprint.answer k [(1,2)] $ [1..n]

myprint [] = putStrLn "-1"
myprint xs = do
    putStrLn.show $ length xs
    mapM_ putStrLn $ map format xs

format (u,v) = show u ++ " " ++ show v

answer k graph [] = if k == 0 then nub graph else []
answer 0 graph (u:xs) = answer 0 (add u graph) xs
answer k graph (u:xs) = case find (==u+2) xs of
    Just v -> answer (k-1) ((min u v, max u v):graph) xs
    Nothing -> answer k (add u graph) xs

add n ((u,v):graph) = if u == n then (min n v, max n v):graph else (min n u, max n u):graph