program friendships
  implicit none
  integer :: n, k, m, x, i, j
  read(*,*) n, k
  m = ((n-1)*(n-2))/2
  if (k.gt.m) then
    write(*,'(i0)') -1
    stop
  end if
  write(*,'(i0)') n-1+m-k
  do i = 2, n
    write(*,'(i0,x,i0)') 1, i
  end do
  x = 0
  do i = 2, n-1
    do j = i+1, n
      if (x.eq.m-k) stop
      x = x+1
      write(*,'(i0,x,i0)') i, j
    end do
  end do
  stop
end program friendships