#include <iostream>
#include <iomanip>
using namespace std;
int n, r, st[21] = {0};
void dfs(int cnt, int base)
{
if (cnt > r)
{
for (int i = 1; i <= n; i++)
if (st[i]) cout << setw(3) << st[i];
cout << endl;
return;
}
for (int i = base; i <= n; i++)
{
if (!st[i])
{
st[i] = i;
dfs(cnt + 1, i + 1);
st[i] = 0;
}
}
}
int main()
{
cin >> n >> r;
dfs(1, 1);
return 0;
}