#include#define MAXN 30000 using namespace std; struct node{ int l,r,m,c; }tree[3*MAXN]; void create(int l,int r,int num){ tree[num].l=l;tree[num].r=r; tree[num].m=(l+r)>>1;tree[num]=r-l; if(l+1!=r){ create(l,tree[num].m,2*num); create(tree[num].m,r,2*num+1); } } int update(int l,int r,int num){ if(tree[num].l==l && tree[num].r==r) return tree[num].c; else if(r<=tree[num].l) update(l,r,2*num); else if(l<=tree[num].r) update(l,r,2*num); else{ update(l,tree[num].m,num); update(tree[num].m,r,num); } } int search(int k,int i){ tree[i].c--; if(tree[i].m==tree[i].l){ printf("%d",t[i].l); return t[i].l } if (t[i].l == t[i].m) { printf("%d ", t[i].l); return t[i].l; } int s = t[i << 1].c; if (k <= s) return find(k, i << 1); return find(k - s, (i << 1) + 1); int s=tree[2*i].c; if(k<=s) return search(k,2*i); else return search(k-s,2*i+1); } int main() { int m,n; int i=0; while(scanf("%d%d",&n,&m)!=EOF){ create(1,n+1,1); while(i=update(1,search((i+m)%t[1].c?(i+m)%t[i].c:t[i].c,1),1)) printf("\n"); } return 0; }