#include<iostream>
#include<vector>
#define INF 10000
using namespace std;
int main(){
    int n,m;
    while(cin>>n>>m,n){
        vector<int>V;
        V.push_back(INF);
        for(int i=1;i<=n;i++)V.push_back(i);
        V.push_back(INF);
        vector<int>::iterator ite=V.begin()+1;
        for(int i=0;i<n-1;i++){
            cout<<i+1<<":";
            for(vector<int>::iterator ii=V.begin();ii!=V.end();ii++)cout<<*ii<<" ";
            cout<<endl;
            for(int j=0;j<m-1;j++){
                ite++;
                if(*ite==INF)ite=V.begin()+1;
            }
            ite=V.erase(ite);
            if(*ite==INF)ite=V.begin()+1;

        }
        cout<<V[1]<<endl;
    }
    return 0;
}