{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}
module Main where
import Data.Function
import Data.List as List
import Data.Char as Char
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as B8

main :: IO ()
main = do
  n:k:_ <- readInts
  let d = (n - 1) * (n - 2) `div` 2 - k;
  if d < 0
    then print (-1)
    else do
    print $ (n - 1) + d
    mapM_ (\(l,r) -> putStrLn $ show l ++ " " ++ show r)
      $ [(1,r)| r <- [2..n]]
    mapM_ (\(l,r) -> putStrLn $ show l ++ " " ++ show r)
      $ take d $ [(l,r) | l <- [1 .. n], r <- [l+1 .. n]]

readInts :: IO [Int]
readInts = List.unfoldr (B8.readInt . B8.dropWhile isSpace) <$> BS.getLine
