{-# OPTIONS_GHC -O2 #-}
import Control.Applicative
import Data.List
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BS
import Data.Maybe (fromJust)

show2 (x,y) = shows x " " ++ show y

f :: [Int] -> [String]
f (n:k:_)
    | node < 0  = ["-1"]
    | otherwise = (show (node + n - 1)) : map show2 (zip (replicate (n-1) 1) [2..n] ++ take node [ (x,y) | x <- [2..n], y <- [2..n], x < y])
    where
      node = (n-1) * (n-2) `div` 2 - k

main :: IO()
main = interact $ unlines . f . map read . words