#include<iostream>
using namespace std;
int A[20],N,R;
bool B[20];
void f(int n){ //n代表存放数字的下标
if(n==R){ //如果全部存放完毕,代表结束返回
for(int i=1;i<=R;i++) {
printf("%3d",A[i]);
}
cout<<endl;
return;
}
for(int i=1;i<=N;i++){
if(B[i]==true&&i>A[n-1]||n==1){
A[n+1]=i;
B[i]=false;
f(n+1);
B[i]=true;//回溯
}
}
}
int main(){
cin>>N>>R;
for(int i=0;i<R;i++) B[i]=true;
f(0);
}