t,s,k;main(n){for(scanf("%d%d",&n,&k);s+9;fflush(!printf("%d\n",s--*~k+~-n%~k)));}