#include <bits/stdc++.h>
using namespace std;
int n,r;
int a[25];
bool vis[25];
void dfs(int dep,int last)
{
if(dep>r)
{
for(int i=1;i<=r;i++) cout<<a[i]<<" ";
cout<<'\n';
return;
}
for(int i=last+1;i<=n;i++)
if(!vis[i])
{
vis[i]=true;
a[dep]=i;
dfs(dep+1,i);
vis[i]=false;
}
}
void work()
{
cin>>n>>r;
dfs(1,0);
}
int main()
{
work();
return 0;
}