import Data.Graph.Inductive.Graph
import Data.List
import Data.Graph.Inductive.PatriciaTree

main = do
  [n,k]<-map read.words<$>getLine
  putStr $ solve n k

solve n k = case ans of
  Nothing -> "-1"
  Just g -> toAns g
  where
  ans = go k addingEdges (mkUGraph [1..n] []) :: (Maybe (Gr () ()))
  addingEdges = [(a,b,())|a<-[1..n-1],b<-[a+1..n-1]]
  go 0 _ g = Just g
  go _ [] _ = Nothing
  go k (e:es) g = go (k-1) es (insEdge e g)
  toAns = unlines . con . map f . go es . sort . edges
    where
    go es [] = es
    go []  _ = []
    go (e:es) (r:rs)
      | e == r = go es rs
      | otherwise = e : go es (r:rs)
    f (a,b) = unwords $ map show [a,b]
    es = [(a,b)|a<-[1..n-1],b<-[a+1..n-1]]
    con es = show (length es):es