integer N,K
integer cnt
read*,N,K
if(K>(N-1)*(N-2)/2)then
  print"(i0)",-1
  stop
endif

print"(i0)",(N-1) +((N-1)*(N-2)/2 - K)
do i=1,n-1
  print"(i0,A,i0)",i," ",N
end do

cnt=0

if( cnt==(N-1)*(N-2)/2 -K )then
  stop
end if

do i=1,n-2
  do j=i+1,n-1
    print"(i0,A,i0)",i," ",j
    cnt=cnt+1
    if( cnt==(N-1)*(N-2)/2 -K )then
      stop
    end if
  end do
end do
end