#include <bits/stdc++.h>
using namespace std;
const int MPOW=17;
const int N=1<<MPOW;
struct BIT
{
int arr[N];
BIT(){fill(arr,arr+N,0);}
void add(int x,int y)
{
for(;x<N;x|=x+1)
arr[x]+=y;
}
int get(int x)
{
int sum=0;
int ret=0;
for(int i=N;i && i+ret-1<N;i>>=1)
{
if(sum+arr[i+ret-1]<=x)
sum+=arr[i+ret-1],
ret+=i;
}
return ret;
}
};
main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n,k;
cin>>n>>k;
BIT soldiers;
for(int i=0;i<n;i++)
soldiers.add(i+1,1);
int K=0;
int N=n;
int t;
while(n)
{
K=(K+k-1)%n;
t=soldiers.get(K);
cout<<t<<' ';
soldiers.add(t,-1);
n--;
}
cout<<endl;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1QT1c9MTc7CmNvbnN0IGludCBOPTE8PE1QT1c7CgpzdHJ1Y3QgQklUCnsKICAgIGludCBhcnJbTl07CiAgICBCSVQoKXtmaWxsKGFycixhcnIrTiwwKTt9CgogICAgdm9pZCBhZGQoaW50IHgsaW50IHkpCiAgICB7CiAgICAgICAgZm9yKDt4PE47eHw9eCsxKQogICAgICAgICAgICBhcnJbeF0rPXk7CiAgICB9CiAgICBpbnQgZ2V0KGludCB4KQogICAgewogICAgICAgIGludCBzdW09MDsKICAgICAgICBpbnQgcmV0PTA7CiAgICAgICAgZm9yKGludCBpPU47aSAmJiBpK3JldC0xPE47aT4+PTEpCiAgICAgICAgewogICAgICAgICAgICBpZihzdW0rYXJyW2krcmV0LTFdPD14KQogICAgICAgICAgICAgICAgc3VtKz1hcnJbaStyZXQtMV0sCiAgICAgICAgICAgICAgICByZXQrPWk7CiAgICAgICAgfQogICAgICAgIHJldHVybiByZXQ7CiAgICB9Cn07CgptYWluKCkKewogICAgaW9zOjpzeW5jX3dpdGhfc3RkaW8oMCk7CiAgICBjaW4udGllKDApOwogICAgaW50IG4sazsKICAgIGNpbj4+bj4+azsKICAgIEJJVCBzb2xkaWVyczsKICAgIGZvcihpbnQgaT0wO2k8bjtpKyspCiAgICAgICAgc29sZGllcnMuYWRkKGkrMSwxKTsKICAgIGludCBLPTA7CiAgICBpbnQgTj1uOwogICAgaW50IHQ7CiAgICB3aGlsZShuKQogICAgewogICAgICAgIEs9KEsray0xKSVuOwogICAgICAgIHQ9c29sZGllcnMuZ2V0KEspOwogICAgICAgIGNvdXQ8PHQ8PCcgJzsKICAgICAgICBzb2xkaWVycy5hZGQodCwtMSk7CiAgICAgICAgbi0tOwogICAgfQogICAgY291dDw8ZW5kbDsKfQo=