#include<stdio.h>
int n,s=1,m,out,a[11]; /*n为所有人数,out为出局的人*/
void josegh( );
int main()
{ int i;
scanf("%d%d",&n,&m);
for (i = 1; i <= n; i++) /*定义数组a,按顺序赋值*/
a[i] = i;
while (n != 0)
josegh ( );
return 0;
}
void josegh ( ) /*每当出局一个人,n减1,数组重新排列*/
{ out = s + m - 1;
while (out > n)
out-= n;
printf ("%d ",a[out]);
n--;
s=out;
for(; out <= n; out++)
a[out] = a[out+1];
}