1 #include<cstdio>
2 #include<iostream>
3 #define mid (L+R)/2
4 #define lc (rt<<1)
5 #define rc (rt<<1|1)
6 #define maxn 1000000
7 using namespace std;
8
9 int Tree[maxn],n,m;
10 void maintain(int rt){Tree[rt] = Tree[lc]+Tree[rc];}
11 void build(int rt,int L,int R){
12 if(L == R) Tree[rt] = 1;
13 else{
14 build(lc,L,mid);
15 build(rc,mid+1,R);
16 maintain(rt);
17 }
18 }
19 void modify(int rt,int L,int R,int pos){
20 if(L == R) Tree[rt] = 0;
21 else{
22 if(pos <= mid) modify(lc,L,mid,pos);
23 else modify(rc,mid+1,R,pos);
24 maintain(rt);
25 }
26 }
27 int query(int rt,int L,int R,int val,int remain){
28 if(L == R) return L;
29 else{
30 if(val <= Tree[lc]+remain) return query(lc,L,mid,val,remain);
31 else return query(rc,mid+1,R,val,remain+Tree[lc]);
32 }
33 }
34
35 int main(){
36 scanf("%d%d",&n,&m);
37
38 build(1,1,n);
39
40 int pos = m,ans;
41 for(int i = n;i >= 1;i--){
42 pos = (pos-1)%(Tree[1]);
43 // printf("###$$%d ",pos+1);
44 ans = query(1,1,n,pos+1,0);
45 printf("%d ",ans);
46 modify(1,1,n,ans);
47 pos += m;
48 // getchar();
49 }
50
51 return 0;
52 }