#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 20;
int n,m;
bool d[N];
int g[N];
void dfs(int u,int start)
{
if((u+n-start)<m)return;//剪枝
if(u==m+1)
{
for (int i = 1; i <= m; i ++ )cout<<g[i]<<" ";
cout<<endl;
return;
}
for (int i = start; i <= n; i ++ )
{
if(!d[i])
{
g[u]=i;
d[i]=true;
dfs(u+1,i+1);
d[i]=false;
}
}
}
int main()
{
cin>>n>>m;
dfs(1,1);
return 0;
}