#include <stdio.h>
#define SIZE 128
void xuat(int A[], int n);
void sinhToHop();
int A[SIZE], n,k;
int main()
{
scanf("%d%d",&n,&k);
for (int i=0;i<n;i++)
A[i]=i;
sinhToHop();
return 0;
}
void sinhToHop()
{
int subA[SIZE]={0};
for (int i=0;i<k;i++)
subA[i]=i;
while (1)
{
xuat(subA,k);
int j;
for (j=k-1;subA[j]==n-k+j && j>=0;j--);
if (j>=0)
subA[j]++;
else return;
for (int jj=j+1;jj<k;jj++)
subA[jj]=subA[jj-1]+1;
}
}
void xuat(int A[], int n)
{
for (int i=0;i<n;i++)
printf("%d ",A[i]);
printf("\n");
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNkZWZpbmUgU0laRSAxMjgKCnZvaWQgeHVhdChpbnQgQVtdLCBpbnQgbik7CnZvaWQgc2luaFRvSG9wKCk7CgppbnQgQVtTSVpFXSwgbixrOwoKaW50IG1haW4oKQp7CglzY2FuZigiJWQlZCIsJm4sJmspOwoJZm9yIChpbnQgaT0wO2k8bjtpKyspCgkJQVtpXT1pOwoJc2luaFRvSG9wKCk7CglyZXR1cm4gMDsKfQoKdm9pZCBzaW5oVG9Ib3AoKQp7CglpbnQgc3ViQVtTSVpFXT17MH07Cglmb3IgKGludCBpPTA7aTxrO2krKykKCQlzdWJBW2ldPWk7Cgl3aGlsZSAoMSkKCXsKCQl4dWF0KHN1YkEsayk7CgkJaW50IGo7CgkJZm9yIChqPWstMTtzdWJBW2pdPT1uLWsraiAmJiBqPj0wO2otLSk7CgkJaWYgKGo+PTApCgkJCXN1YkFbal0rKzsKCQllbHNlIHJldHVybjsKCQlmb3IgKGludCBqaj1qKzE7amo8aztqaisrKQoJCQlzdWJBW2pqXT1zdWJBW2pqLTFdKzE7Cgl9Cn0KCnZvaWQgeHVhdChpbnQgQVtdLCBpbnQgbikKewoJZm9yIChpbnQgaT0wO2k8bjtpKyspCgkJcHJpbnRmKCIlZCAiLEFbaV0pOwoJcHJpbnRmKCJcbiIpOwp9