program em
implicit none
integer::N,M
integer::i,j,sa
logical,allocatable,dimension(:)::OK
integer cnt
read*,N,M
allocate(OK(N))
OK=.true.
select case(mod(N,2))
case (0)
  cnt=0
  do sa=1,N/2-1
    do i=1,N
      if(OK(i).and.OK(mod(i+sa-1,N)+1))then
        print"(I0,A,i0)",i," ",mod(i+sa-1,N)+1
        OK(i)=.false.;OK(mod(i+sa-1,N)+1)=.false.
        cnt=cnt+1
        exit
      endif
      if(OK(i).and.OK(mod(i+N-sa-1,N)+1))then
        print"(I0,A,i0)",i," ",mod(i+N-sa-1,N)+1
        OK(i)=.false.;OK(mod(i+N-sa-1,N)+1)=.false.
        cnt=cnt+1
        exit
      endif
    end do
    if(cnt==M)exit
  end do

case(1)
  do i=1,M
    print"(I0,A,i0)",N/2+1-i," ",N/2+i
  end do
end select
contains
end program em