($n,$k)=<>=~/\d+/g;$v=$|++;do{print$v+=($n-$v-1)%($k+1),$/;$v=<>}while$v<$n